├── Chapter09 ├── bin │ ├── python │ ├── python2 │ ├── python2.7 │ ├── pip │ ├── pip2 │ ├── pip2.7 │ ├── flask │ ├── wheel │ ├── easy_install │ ├── easy_install-2.7 │ ├── activate.csh │ ├── activate_this.py │ ├── activate │ ├── activate.fish │ └── python-config ├── pip-selfcheck.json ├── include │ └── python2.7 ├── images │ ├── row 1.png │ ├── CVaaS Page.png │ ├── CVaaS Overview.png │ └── Canny Example.png ├── temp_image.jpg ├── Client │ ├── index.html │ └── index.js ├── Server │ └── app.py ├── corners.py └── app.py ├── Chapter07 ├── codes │ ├── read.py │ ├── write.py │ ├── crop.py │ ├── gray.py │ ├── median_blur.py │ ├── gaussian.py │ ├── canny.py │ ├── resize.py │ ├── erosion.py │ ├── dilation.py │ ├── rotation.py │ ├── filter.py │ ├── thresholding.py │ ├── translation.py │ ├── sobel.py │ ├── contours.py │ └── contour.py └── images │ ├── image.jpg │ ├── filter_kernel.png │ ├── rotation_matrix.png │ ├── combine_canny_image.jpg │ ├── combine_crop_image.jpg │ ├── combine_filter_image.jpg │ ├── combine_gray_images.jpg │ ├── combine_resize_image.jpg │ ├── combine_rotate_image.jpg │ ├── combine_sobelx_image.jpg │ ├── combine_sobely_image.jpg │ ├── translation_matrix.png │ ├── combine_contour_image.jpg │ ├── combine_dilation_image.jpg │ ├── combine_erosion_image.jpg │ ├── combine_median_blur_image.jpg │ ├── combine_translation_image.jpg │ ├── combine_gaussian_blur_image.jpg │ └── combine_thresholding_image.jpg ├── Chapter01 ├── codes │ ├── pillow_read_image.py │ ├── image.png │ ├── new_image.png │ ├── pillow_write_image.py │ ├── skimage_read_image.py │ ├── skimage_write_image.py │ ├── pillow_rotate_image.py │ ├── pillow_resize_image.py │ ├── pillow_crop_image.py │ ├── pillow_image_enhance.py │ ├── pillow_rgb_gray.py │ ├── skimage_data.py │ ├── skimage_rgb_gray.py │ ├── skimage_rgb_hsv.py │ ├── skimage_draw_image.py │ ├── skimage_draw_eclipse_image.py │ ├── pillow_image_contrast.py │ └── skimage_draw_polygon_image.py └── images │ ├── cmyk.jpg │ ├── hsv.png │ ├── maths.png │ ├── tumor.png │ ├── camera.png │ ├── circle.png │ ├── ellipse.png │ ├── polygon.png │ ├── chapter1.docx │ ├── lena_blue.png │ ├── lena_green.png │ ├── lena_page1.png │ ├── lena_red.png │ ├── chapter1_up.docx │ ├── lena_bright.png │ ├── lena_cropped.png │ ├── lena_general.png │ ├── lena_contrast.png │ ├── lena_rotated_90.png │ ├── lena_black_white.png │ └── lena_matrix_page1.png ├── Chapter08 ├── gray.png ├── color_track.jpg ├── Screen Shot 2017-06-03 at 11.06.48 PM.png └── codes │ ├── gray.py │ ├── farneback.py │ └── lk_opticalflow.py ├── Chapter03 ├── code │ ├── test.png │ ├── harris.py │ ├── orb.py │ ├── lbp.py │ └── stitch.py └── images │ ├── ORB1.png │ ├── ORB2.png │ ├── ORB3.png │ ├── ORB4.png │ ├── ORB5.png │ ├── ORB6.png │ ├── ORB7.png │ ├── ORB8.png │ ├── output.jpg │ ├── DoG SIFT.png │ ├── ORB Result.png │ ├── output_old.jpg │ ├── LBP Features.png │ ├── goldengate1.png │ ├── goldengate2.png │ ├── Haar Cascades.png │ ├── Harris Corner.png │ ├── harris_output.png │ ├── panorama example.png │ ├── Harris Corner Equation.png │ └── Keypoint Localisation.png ├── Chapter02 ├── codes │ ├── image.jpg │ ├── image.png │ ├── input_save.jpg │ ├── thresh_out.jpg │ ├── thresh_out.png │ ├── adaptive_thresh.jpg │ ├── erosion.py │ ├── gaussain_blur_pillow.py │ ├── gaussian_filter_scikit.py │ ├── Sobel_scikit.py │ ├── canny_edge_scikit.py │ ├── create_filter.py │ ├── gaussian_distribution.py │ ├── harris.py │ ├── hough_lines.py │ └── thresholding.py └── images │ ├── image.jpg │ ├── black_box.png │ ├── gaussian_1.png │ ├── convolution.jpg │ ├── harriswindow.jpg │ ├── sobel_kernel.png │ ├── convolution_ex2.png │ ├── derivative_eq.png │ ├── dilation_image.png │ ├── dilation_matrix.png │ ├── equation_circle.png │ ├── erosion_image.png │ ├── erosion_matrix.png │ ├── line_equation.png │ ├── line_equation1.png │ ├── line_equation2.png │ ├── gaussian-function.jpg │ ├── gradient_formula.gif │ ├── gradient_formula.png │ ├── image_derivative.jpg │ ├── non_maximal_supression.png │ ├── combine_images_canny_edge.jpg │ ├── combine_images_sobel_edge.jpg │ ├── derivative_mask_example.png │ ├── combine_images_createfilter.jpg │ ├── combine_images_gaussian_blur_pillow.jpg │ └── combine_images_gaussian_filter_scikit.jpg ├── Chapter05 ├── codes │ ├── digit.png │ ├── mnist_pca.png │ ├── SVM.py │ ├── pca.py │ ├── KMeans.py │ ├── LR.py │ ├── LR_user_input.py │ ├── tsne.py │ └── plot_kmeans_digits.py └── Images │ ├── digit_6.png │ ├── PCA output.png │ ├── baseball.jpg │ ├── TSNE output.png │ ├── mnistdigits.gif │ ├── svm-variations.png │ └── separating-lines-svm.png ├── Chapter06 ├── images │ ├── pug.jpg │ ├── perceptron.png │ ├── NN Flow chart.png │ ├── neural network.png │ └── perceptron formula.png └── codes │ └── mlp.py ├── Chapter10 ├── codes │ ├── image.jpg │ ├── output.jpg │ ├── image_rot.jpg │ ├── combined out.png │ ├── sift_matches.jpg │ ├── gradient_formula.png │ ├── sift_keypoints.jpg │ ├── face_detection.py │ └── sift.py └── images │ ├── DoG.png │ ├── Keypoint.png │ ├── extremum.png │ ├── haar_demo.png │ ├── sift_dog.jpg │ ├── surf_lxy.png │ ├── SIFT Octave.png │ ├── integral sum.png │ ├── sift-octaves.jpg │ ├── Approx formula.png │ ├── Haar Features.png │ ├── efficient sum.png │ ├── SURF Box filters.png │ ├── SURF orientation.png │ ├── Subpixel formula.png │ ├── haar_features_new.jpg │ ├── sift_orieintation.png │ ├── surf_orientation.jpg │ ├── Descriptor histogram.png │ ├── haar_combined_demo.png │ ├── orientation formula.png │ └── sift_local_extrema.jpg ├── Chapter04 ├── images │ ├── contours.png │ ├── original.png │ ├── segmented.png │ ├── watershed.png │ ├── superpixels.png │ ├── contours example.png │ ├── watershed_output.png │ ├── segmentation example.png │ ├── watershed_astronaut.png │ └── graph_cut_illustration.png └── CODES │ ├── superpixels.py │ ├── contours.py │ ├── plot_ncut.py │ └── plot_marked_watershed.py ├── LICENSE └── README.md /Chapter09/bin/python: -------------------------------------------------------------------------------- 1 | python2.7 -------------------------------------------------------------------------------- /Chapter09/bin/python2: -------------------------------------------------------------------------------- 1 | python2.7 -------------------------------------------------------------------------------- /Chapter09/pip-selfcheck.json: -------------------------------------------------------------------------------- 1 | {"last_check":"2017-07-22T22:00:20Z","pypi_version":"9.0.1"} -------------------------------------------------------------------------------- /Chapter07/codes/read.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | cv2.imshow("image",img) -------------------------------------------------------------------------------- /Chapter07/codes/write.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | cv2.imwrite("saved_image.jpg", img) 4 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_read_image.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | img = Image.open('image.png') 4 | img.show() 5 | -------------------------------------------------------------------------------- /Chapter08/gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter08/gray.png -------------------------------------------------------------------------------- /Chapter09/include/python2.7: -------------------------------------------------------------------------------- 1 | /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/include/python2.7 -------------------------------------------------------------------------------- /Chapter03/code/test.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/code/test.png -------------------------------------------------------------------------------- /Chapter09/bin/python2.7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/bin/python2.7 -------------------------------------------------------------------------------- /Chapter01/codes/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/codes/image.png -------------------------------------------------------------------------------- /Chapter01/images/cmyk.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/cmyk.jpg -------------------------------------------------------------------------------- /Chapter01/images/hsv.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/hsv.png -------------------------------------------------------------------------------- /Chapter01/images/maths.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/maths.png -------------------------------------------------------------------------------- /Chapter01/images/tumor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/tumor.png -------------------------------------------------------------------------------- /Chapter02/codes/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/image.jpg -------------------------------------------------------------------------------- /Chapter02/codes/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/image.png -------------------------------------------------------------------------------- /Chapter02/images/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/image.jpg -------------------------------------------------------------------------------- /Chapter03/images/ORB1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB1.png -------------------------------------------------------------------------------- /Chapter03/images/ORB2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB2.png -------------------------------------------------------------------------------- /Chapter03/images/ORB3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB3.png -------------------------------------------------------------------------------- /Chapter03/images/ORB4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB4.png -------------------------------------------------------------------------------- /Chapter03/images/ORB5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB5.png -------------------------------------------------------------------------------- /Chapter03/images/ORB6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB6.png -------------------------------------------------------------------------------- /Chapter03/images/ORB7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB7.png -------------------------------------------------------------------------------- /Chapter03/images/ORB8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB8.png -------------------------------------------------------------------------------- /Chapter05/codes/digit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/codes/digit.png -------------------------------------------------------------------------------- /Chapter06/images/pug.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter06/images/pug.jpg -------------------------------------------------------------------------------- /Chapter07/images/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/image.jpg -------------------------------------------------------------------------------- /Chapter08/color_track.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter08/color_track.jpg -------------------------------------------------------------------------------- /Chapter09/images/row 1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/images/row 1.png -------------------------------------------------------------------------------- /Chapter09/temp_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/temp_image.jpg -------------------------------------------------------------------------------- /Chapter10/codes/image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/image.jpg -------------------------------------------------------------------------------- /Chapter10/codes/output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/output.jpg -------------------------------------------------------------------------------- /Chapter10/images/DoG.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/DoG.png -------------------------------------------------------------------------------- /Chapter01/images/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/camera.png -------------------------------------------------------------------------------- /Chapter01/images/circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/circle.png -------------------------------------------------------------------------------- /Chapter01/images/ellipse.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/ellipse.png -------------------------------------------------------------------------------- /Chapter01/images/polygon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/polygon.png -------------------------------------------------------------------------------- /Chapter03/images/output.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/output.jpg -------------------------------------------------------------------------------- /Chapter05/Images/digit_6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/digit_6.png -------------------------------------------------------------------------------- /Chapter01/codes/new_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/codes/new_image.png -------------------------------------------------------------------------------- /Chapter01/images/chapter1.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/chapter1.docx -------------------------------------------------------------------------------- /Chapter01/images/lena_blue.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_blue.png -------------------------------------------------------------------------------- /Chapter01/images/lena_green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_green.png -------------------------------------------------------------------------------- /Chapter01/images/lena_page1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_page1.png -------------------------------------------------------------------------------- /Chapter01/images/lena_red.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_red.png -------------------------------------------------------------------------------- /Chapter02/codes/input_save.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/input_save.jpg -------------------------------------------------------------------------------- /Chapter02/codes/thresh_out.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/thresh_out.jpg -------------------------------------------------------------------------------- /Chapter02/codes/thresh_out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/thresh_out.png -------------------------------------------------------------------------------- /Chapter02/images/black_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/black_box.png -------------------------------------------------------------------------------- /Chapter02/images/gaussian_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/gaussian_1.png -------------------------------------------------------------------------------- /Chapter03/images/DoG SIFT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/DoG SIFT.png -------------------------------------------------------------------------------- /Chapter03/images/ORB Result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/ORB Result.png -------------------------------------------------------------------------------- /Chapter03/images/output_old.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/output_old.jpg -------------------------------------------------------------------------------- /Chapter04/images/contours.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/contours.png -------------------------------------------------------------------------------- /Chapter04/images/original.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/original.png -------------------------------------------------------------------------------- /Chapter04/images/segmented.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/segmented.png -------------------------------------------------------------------------------- /Chapter04/images/watershed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/watershed.png -------------------------------------------------------------------------------- /Chapter05/Images/PCA output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/PCA output.png -------------------------------------------------------------------------------- /Chapter05/Images/baseball.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/baseball.jpg -------------------------------------------------------------------------------- /Chapter05/codes/mnist_pca.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/codes/mnist_pca.png -------------------------------------------------------------------------------- /Chapter06/images/perceptron.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter06/images/perceptron.png -------------------------------------------------------------------------------- /Chapter09/images/CVaaS Page.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/images/CVaaS Page.png -------------------------------------------------------------------------------- /Chapter10/codes/image_rot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/image_rot.jpg -------------------------------------------------------------------------------- /Chapter10/images/Keypoint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/Keypoint.png -------------------------------------------------------------------------------- /Chapter10/images/extremum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/extremum.png -------------------------------------------------------------------------------- /Chapter10/images/haar_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/haar_demo.png -------------------------------------------------------------------------------- /Chapter10/images/sift_dog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/sift_dog.jpg -------------------------------------------------------------------------------- /Chapter10/images/surf_lxy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/surf_lxy.png -------------------------------------------------------------------------------- /Chapter01/images/chapter1_up.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/chapter1_up.docx -------------------------------------------------------------------------------- /Chapter01/images/lena_bright.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_bright.png -------------------------------------------------------------------------------- /Chapter01/images/lena_cropped.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_cropped.png -------------------------------------------------------------------------------- /Chapter01/images/lena_general.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_general.png -------------------------------------------------------------------------------- /Chapter02/images/convolution.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/convolution.jpg -------------------------------------------------------------------------------- /Chapter02/images/harriswindow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/harriswindow.jpg -------------------------------------------------------------------------------- /Chapter02/images/sobel_kernel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/sobel_kernel.png -------------------------------------------------------------------------------- /Chapter03/images/LBP Features.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/LBP Features.png -------------------------------------------------------------------------------- /Chapter03/images/goldengate1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/goldengate1.png -------------------------------------------------------------------------------- /Chapter03/images/goldengate2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/goldengate2.png -------------------------------------------------------------------------------- /Chapter04/images/superpixels.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/superpixels.png -------------------------------------------------------------------------------- /Chapter05/Images/TSNE output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/TSNE output.png -------------------------------------------------------------------------------- /Chapter05/Images/mnistdigits.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/mnistdigits.gif -------------------------------------------------------------------------------- /Chapter10/codes/combined out.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/combined out.png -------------------------------------------------------------------------------- /Chapter10/codes/sift_matches.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/sift_matches.jpg -------------------------------------------------------------------------------- /Chapter10/images/SIFT Octave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/SIFT Octave.png -------------------------------------------------------------------------------- /Chapter10/images/integral sum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/integral sum.png -------------------------------------------------------------------------------- /Chapter10/images/sift-octaves.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/sift-octaves.jpg -------------------------------------------------------------------------------- /Chapter01/images/lena_contrast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_contrast.png -------------------------------------------------------------------------------- /Chapter01/images/lena_rotated_90.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_rotated_90.png -------------------------------------------------------------------------------- /Chapter02/codes/adaptive_thresh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/codes/adaptive_thresh.jpg -------------------------------------------------------------------------------- /Chapter02/images/convolution_ex2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/convolution_ex2.png -------------------------------------------------------------------------------- /Chapter02/images/derivative_eq.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/derivative_eq.png -------------------------------------------------------------------------------- /Chapter02/images/dilation_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/dilation_image.png -------------------------------------------------------------------------------- /Chapter02/images/dilation_matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/dilation_matrix.png -------------------------------------------------------------------------------- /Chapter02/images/equation_circle.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/equation_circle.png -------------------------------------------------------------------------------- /Chapter02/images/erosion_image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/erosion_image.png -------------------------------------------------------------------------------- /Chapter02/images/erosion_matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/erosion_matrix.png -------------------------------------------------------------------------------- /Chapter02/images/line_equation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/line_equation.png -------------------------------------------------------------------------------- /Chapter02/images/line_equation1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/line_equation1.png -------------------------------------------------------------------------------- /Chapter02/images/line_equation2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/line_equation2.png -------------------------------------------------------------------------------- /Chapter03/images/Haar Cascades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/Haar Cascades.png -------------------------------------------------------------------------------- /Chapter03/images/Harris Corner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/Harris Corner.png -------------------------------------------------------------------------------- /Chapter03/images/harris_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/harris_output.png -------------------------------------------------------------------------------- /Chapter05/Images/svm-variations.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/svm-variations.png -------------------------------------------------------------------------------- /Chapter06/images/NN Flow chart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter06/images/NN Flow chart.png -------------------------------------------------------------------------------- /Chapter06/images/neural network.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter06/images/neural network.png -------------------------------------------------------------------------------- /Chapter07/images/filter_kernel.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/filter_kernel.png -------------------------------------------------------------------------------- /Chapter07/images/rotation_matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/rotation_matrix.png -------------------------------------------------------------------------------- /Chapter09/images/CVaaS Overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/images/CVaaS Overview.png -------------------------------------------------------------------------------- /Chapter09/images/Canny Example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter09/images/Canny Example.png -------------------------------------------------------------------------------- /Chapter10/codes/gradient_formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/gradient_formula.png -------------------------------------------------------------------------------- /Chapter10/codes/sift_keypoints.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/codes/sift_keypoints.jpg -------------------------------------------------------------------------------- /Chapter10/images/Approx formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/Approx formula.png -------------------------------------------------------------------------------- /Chapter10/images/Haar Features.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/Haar Features.png -------------------------------------------------------------------------------- /Chapter10/images/efficient sum.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/efficient sum.png -------------------------------------------------------------------------------- /Chapter01/images/lena_black_white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_black_white.png -------------------------------------------------------------------------------- /Chapter01/images/lena_matrix_page1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter01/images/lena_matrix_page1.png -------------------------------------------------------------------------------- /Chapter02/images/gaussian-function.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/gaussian-function.jpg -------------------------------------------------------------------------------- /Chapter02/images/gradient_formula.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/gradient_formula.gif -------------------------------------------------------------------------------- /Chapter02/images/gradient_formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/gradient_formula.png -------------------------------------------------------------------------------- /Chapter02/images/image_derivative.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/image_derivative.jpg -------------------------------------------------------------------------------- /Chapter03/images/panorama example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/panorama example.png -------------------------------------------------------------------------------- /Chapter04/images/contours example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/contours example.png -------------------------------------------------------------------------------- /Chapter04/images/watershed_output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/watershed_output.png -------------------------------------------------------------------------------- /Chapter10/images/SURF Box filters.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/SURF Box filters.png -------------------------------------------------------------------------------- /Chapter10/images/SURF orientation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/SURF orientation.png -------------------------------------------------------------------------------- /Chapter10/images/Subpixel formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/Subpixel formula.png -------------------------------------------------------------------------------- /Chapter10/images/haar_features_new.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/haar_features_new.jpg -------------------------------------------------------------------------------- /Chapter10/images/sift_orieintation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/sift_orieintation.png -------------------------------------------------------------------------------- /Chapter10/images/surf_orientation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/surf_orientation.jpg -------------------------------------------------------------------------------- /Chapter04/images/segmentation example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/segmentation example.png -------------------------------------------------------------------------------- /Chapter04/images/watershed_astronaut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/watershed_astronaut.png -------------------------------------------------------------------------------- /Chapter05/Images/separating-lines-svm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter05/Images/separating-lines-svm.png -------------------------------------------------------------------------------- /Chapter06/images/perceptron formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter06/images/perceptron formula.png -------------------------------------------------------------------------------- /Chapter07/images/combine_canny_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_canny_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_crop_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_crop_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_filter_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_filter_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_gray_images.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_gray_images.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_resize_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_resize_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_rotate_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_rotate_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_sobelx_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_sobelx_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_sobely_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_sobely_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/translation_matrix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/translation_matrix.png -------------------------------------------------------------------------------- /Chapter10/images/Descriptor histogram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/Descriptor histogram.png -------------------------------------------------------------------------------- /Chapter10/images/haar_combined_demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/haar_combined_demo.png -------------------------------------------------------------------------------- /Chapter10/images/orientation formula.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/orientation formula.png -------------------------------------------------------------------------------- /Chapter10/images/sift_local_extrema.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter10/images/sift_local_extrema.jpg -------------------------------------------------------------------------------- /Chapter02/images/non_maximal_supression.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/non_maximal_supression.png -------------------------------------------------------------------------------- /Chapter03/images/Harris Corner Equation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/Harris Corner Equation.png -------------------------------------------------------------------------------- /Chapter03/images/Keypoint Localisation.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter03/images/Keypoint Localisation.png -------------------------------------------------------------------------------- /Chapter04/images/graph_cut_illustration.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter04/images/graph_cut_illustration.png -------------------------------------------------------------------------------- /Chapter07/images/combine_contour_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_contour_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_dilation_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_dilation_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_erosion_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_erosion_image.jpg -------------------------------------------------------------------------------- /Chapter02/images/combine_images_canny_edge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/combine_images_canny_edge.jpg -------------------------------------------------------------------------------- /Chapter02/images/combine_images_sobel_edge.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/combine_images_sobel_edge.jpg -------------------------------------------------------------------------------- /Chapter02/images/derivative_mask_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/derivative_mask_example.png -------------------------------------------------------------------------------- /Chapter07/images/combine_median_blur_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_median_blur_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_translation_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_translation_image.jpg -------------------------------------------------------------------------------- /Chapter02/images/combine_images_createfilter.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/combine_images_createfilter.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_gaussian_blur_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_gaussian_blur_image.jpg -------------------------------------------------------------------------------- /Chapter07/images/combine_thresholding_image.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter07/images/combine_thresholding_image.jpg -------------------------------------------------------------------------------- /Chapter07/codes/crop.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | img_crop = img[0:200, 150:350] 4 | cv2.imwrite("crop_img.jpg", img_crop) 5 | cv2.imshow("crop", img_crop) 6 | -------------------------------------------------------------------------------- /Chapter08/Screen Shot 2017-06-03 at 11.06.48 PM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter08/Screen Shot 2017-06-03 at 11.06.48 PM.png -------------------------------------------------------------------------------- /Chapter02/images/combine_images_gaussian_blur_pillow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/combine_images_gaussian_blur_pillow.jpg -------------------------------------------------------------------------------- /Chapter07/codes/gray.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 4 | cv2.imwrite("gray_image.jpg", gray) 5 | cv2.imshow("image",gray) 6 | -------------------------------------------------------------------------------- /Chapter02/images/combine_images_gaussian_filter_scikit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PacktPublishing/Computer-Vision-with-Python-3/HEAD/Chapter02/images/combine_images_gaussian_filter_scikit.jpg -------------------------------------------------------------------------------- /Chapter01/codes/pillow_write_image.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | 3 | #Open any image 4 | img = Image.open('image.png') 5 | #Save the image with a different name 6 | img.save('new_image.png') 7 | 8 | -------------------------------------------------------------------------------- /Chapter07/codes/median_blur.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | new_img = cv2.medianBlur(img,5) 4 | cv2.imwrite("median_blur.jpg", new_img) 5 | cv2.imshow("median_blur", new_img) 6 | -------------------------------------------------------------------------------- /Chapter02/codes/erosion.py: -------------------------------------------------------------------------------- 1 | from skimage import morphology 2 | from skimage import io 3 | 4 | img = io.imread('image.png') 5 | eroded_img = morphology.erode(img) 6 | 7 | io.imshow(eroded_img) 8 | io.show() 9 | -------------------------------------------------------------------------------- /Chapter07/codes/gaussian.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | new_img = cv2.GaussianBlur(img,(5,5),0) 4 | cv2.imwrite("gaussian_blur.jpg", new_img) 5 | cv2.imshow("gaussian_blur.jpg", new_img) 6 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_read_image.py: -------------------------------------------------------------------------------- 1 | #Program to read an image using skimage 2 | 3 | from skimage import io 4 | 5 | #Read image 6 | img = io.imread('image.png') 7 | io.imshow(img) 8 | io.show() 9 | 10 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_write_image.py: -------------------------------------------------------------------------------- 1 | #Program to write an image 2 | 3 | from skimage import io 4 | 5 | #Read an image 6 | img = io.imread('image.png') 7 | 8 | #Write an image to a file 9 | io.imsave('new_image.png', img) 10 | -------------------------------------------------------------------------------- /Chapter02/codes/gaussain_blur_pillow.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | from PIL import ImageFilter 3 | img = Image.open("image.jpg") 4 | blur_img = img.filter(ImageFilter.GaussianBlur(5)) 5 | blur_img.save("GaussianBlur.jpg") 6 | blur_img.show() -------------------------------------------------------------------------------- /Chapter07/codes/canny.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 4 | edges = cv2.Canny(gray, 100, 200, 3) 5 | cv2.imwrite("canny_edges.jpg", edges) 6 | cv2.imshow("canny_edges", edges) 7 | -------------------------------------------------------------------------------- /Chapter07/codes/resize.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | r,c = img.shape[:2] 4 | new_img = cv2.resize(img, (2*r,2*c), interpolation = cv2.INTER_CUBIC) 5 | cv2.imwrite("resize_image.jpg", new_img) 6 | cv2.imshow("resize", new_img) -------------------------------------------------------------------------------- /Chapter02/codes/gaussian_filter_scikit.py: -------------------------------------------------------------------------------- 1 | from skimage import io 2 | from skimage import filters 3 | img = io.imread("image.jpg") 4 | out = filters.gaussian(img, sigma=5) 5 | io.imsave("gaussian_filter_scikit.jpg", out) 6 | io.imshow(out) 7 | io.show() -------------------------------------------------------------------------------- /Chapter07/codes/erosion.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | img = cv2.imread("thresholding.jpg") 4 | ker = np.ones((5,5),np.uint8) 5 | new_img = cv2.erode(img,ker,iterations = 1) 6 | cv2.imwrite("erosion.jpg", new_img) 7 | cv2.imshow("erosion", new_img) 8 | -------------------------------------------------------------------------------- /Chapter07/codes/dilation.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | img = cv2.imread("thresholding.jpg") 4 | ker = np.ones((5,5),np.uint8) 5 | new_img = cv2.dilate(img,ker,iterations = 1) 6 | cv2.imwrite("dilation.jpg", new_img) 7 | cv2.imshow("dilation", new_img) 8 | -------------------------------------------------------------------------------- /Chapter07/codes/rotation.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | r,c = img.shape[:2] 4 | M = cv2.getRotationMatrix2D((c/2,r/2),90,1) 5 | new_img = cv2.warpAffine(img,M,(c,r)) 6 | cv2.imwrite("rotate_img.jpg", new_img) 7 | cv2.imshow("rotate", new_img) 8 | -------------------------------------------------------------------------------- /Chapter02/codes/Sobel_scikit.py: -------------------------------------------------------------------------------- 1 | from skimage import io 2 | from skimage import filters 3 | from skimage import color 4 | img = io.imread("image.jpg") 5 | img = color.rgb2gray(img) 6 | edge = filters.sobel(img) 7 | io.imshow(edge) 8 | io.imsave("sobel_edge.jpg", edge) 9 | io.show() -------------------------------------------------------------------------------- /Chapter07/codes/filter.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | img = cv2.imread("image.jpg") 4 | ker = np.array([[1, 1, 1], 5 | [1, 1, 1], 6 | [1, 1, 1]]) 7 | new_img = cv2.filter2D(img,-1,ker) 8 | cv2.imwrite("filter.jpg", new_img) 9 | cv2.imshow("filter", new_img) 10 | -------------------------------------------------------------------------------- /Chapter07/codes/thresholding.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 4 | new_img = cv2.threshold(gray,120,255,cv2.THRESH_BINARY) 5 | cv2.imwrite("thresholding.jpg", new_img[1]) 6 | cv2.imshow("thresholding", new_img[1]) 7 | -------------------------------------------------------------------------------- /Chapter02/codes/canny_edge_scikit.py: -------------------------------------------------------------------------------- 1 | from skimage import io 2 | from skimage import feature 3 | from skimage import color 4 | img = io.imread("image.jpg") 5 | img = color.rgb2gray(img) 6 | edge = feature.canny(img,3) 7 | io.imshow(edge) 8 | io.imsave("canny_edge.jpg", edge) 9 | io.show() -------------------------------------------------------------------------------- /Chapter02/codes/create_filter.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | from PIL import ImageFilter 3 | img = Image.open("image.jpg") 4 | img = img.convert("L") 5 | new_img = img.filter(ImageFilter.Kernel((3,3),[1,0,-1,5,0,-5,1,0,1])) 6 | new_img.save("create_filter_image.jpg") 7 | new_img.show() 8 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_rotate_image.py: -------------------------------------------------------------------------------- 1 | #Program to rotate an image 2 | 3 | from PIL import Image 4 | 5 | #Read the image 6 | img = Image.read('image.png') 7 | 8 | #Rotate the image by 90 degress anti-clockwise 9 | rotated_img = img.rotate(90) 10 | 11 | rotated_img.show() 12 | -------------------------------------------------------------------------------- /Chapter02/codes/gaussian_distribution.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | import numpy as np 3 | import matplotlib.mlab as mlab 4 | import math 5 | 6 | mu = 0 7 | sigma = 0.1 8 | x = np.linspace(-3, 3, 100) 9 | plt.plot(x,mlab.normpdf(x, mu, sigma)) 10 | 11 | plt.show() 12 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_resize_image.py: -------------------------------------------------------------------------------- 1 | #Program to resize a given image 2 | 3 | from PIL import Image 4 | 5 | #Read the image that you want to resize 6 | img = Image.open('image.png') 7 | 8 | #Resize the image 9 | resize_img = img.resize((200, 200)) 10 | 11 | resize_img.show() 12 | -------------------------------------------------------------------------------- /Chapter07/codes/translation.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | img = cv2.imread("image.jpg") 4 | r,c = img.shape[:2] 5 | M = np.float32([[1,0,100],[0,1,100]]) 6 | new_img = cv2.warpAffine(img,M,(c,r)) 7 | cv2.imwrite("translation.jpg", new_img) 8 | cv2.imshow("translation", new_img) 9 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_crop_image.py: -------------------------------------------------------------------------------- 1 | #Program to crop an image 2 | 3 | from PIL import Image 4 | 5 | #Read the image that you want to crop 6 | img = Image.open('image.png') 7 | 8 | #Create a dimension tuple 9 | dim = (100, 100, 400, 400) 10 | crop_img = img.crop(dim) 11 | 12 | crop_img.show() 13 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_image_enhance.py: -------------------------------------------------------------------------------- 1 | #Program to enhance an image 2 | 3 | from PIL import Image 4 | from PIL import ImageEnhance 5 | 6 | #Read an image 7 | img = Image.open('image.png') 8 | 9 | enchancer = ImageEnhance.Brightness(img) 10 | bright_img = enhancer.enhance(2) 11 | 12 | bright_img.show() 13 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_rgb_gray.py: -------------------------------------------------------------------------------- 1 | #Program to convert RGB images to Gray scale images 2 | 3 | from PIL import Image 4 | 5 | #Read the image that you wnat to convert 6 | img = Image.open('image.png') 7 | 8 | #Convert the image to grayscale 9 | gray_image = img.convert("L") 10 | 11 | gray_image.show() 12 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_data.py: -------------------------------------------------------------------------------- 1 | #Program to get default images in scikit-image 2 | 3 | from skimage import data 4 | from skimage import io 5 | 6 | #Get the camera image 7 | img_camera = data.camera() 8 | 9 | #Get an image with handwritten text 10 | img_text = data.text() 11 | 12 | io.show(img_text) 13 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_rgb_gray.py: -------------------------------------------------------------------------------- 1 | #Program to convert a color image to grayscale image 2 | 3 | from skimage import color, io 4 | 5 | #Read an image from a file 6 | img = io.imread('image.png') 7 | 8 | #Convert the image tp grayscale 9 | gray_image = color.rgb2gray(img) 10 | 11 | io.imshow(gray_image) 12 | io.show() 13 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_rgb_hsv.py: -------------------------------------------------------------------------------- 1 | #Program to convert a color image to grayscale image 2 | 3 | from skimage import color, io 4 | 5 | #Read an image from a file 6 | img = io.imread('image.png') 7 | 8 | #Convert the image tp grayscale 9 | hsv_image = color.rgb2hsv(img) 10 | 11 | io.imshow(hsv_image) 12 | io.show() 13 | -------------------------------------------------------------------------------- /Chapter09/bin/pip: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from pip import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter09/bin/pip2: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from pip import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter09/bin/pip2.7: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from pip import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_draw_image.py: -------------------------------------------------------------------------------- 1 | #Program to draw a circle on a black image 2 | 3 | import numpy as np 4 | from skimage import io, draw 5 | 6 | #Read an image 7 | img = np.zeros((100, 100), dtype=np.uint8) 8 | 9 | #Draw a circle 10 | x, y = draw.circle(50, 50, 10) 11 | img[x, y] = 1 12 | 13 | io.imshow(img) 14 | io.show() 15 | -------------------------------------------------------------------------------- /Chapter09/bin/flask: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from flask.cli import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter09/bin/wheel: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from wheel.tool import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_draw_eclipse_image.py: -------------------------------------------------------------------------------- 1 | #Program to draw an eclipse on a black image 2 | 3 | import numpy as np 4 | from skimage import io, draw 5 | 6 | #Read an image 7 | img = np.zeros((100, 100), dtype=np.uint8) 8 | 9 | #Draw a circle 10 | x, y = draw.ellipse(50, 50, 10, 20) 11 | img[x, y] = 1 12 | 13 | io.imshow(img) 14 | io.show() 15 | -------------------------------------------------------------------------------- /Chapter01/codes/pillow_image_contrast.py: -------------------------------------------------------------------------------- 1 | #Program to change the brightness 2 | 3 | from PIL import Image 4 | from PIL import ImageEnhancer 5 | 6 | #Read the image 7 | img = Image.open('image.png') 8 | 9 | #Change the constrast of the image 10 | enhancer = ImageEnhancer.Contrast(img) 11 | 12 | new_img = enhancer.enchance(2) 13 | 14 | new_img.show() 15 | -------------------------------------------------------------------------------- /Chapter09/bin/easy_install: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from setuptools.command.easy_install import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter09/bin/easy_install-2.7: -------------------------------------------------------------------------------- 1 | #!/Users/salil/Work/Book_CV_Using_Python3/Chapter9/CVaaS/flask/bin/python2.7 2 | 3 | # -*- coding: utf-8 -*- 4 | import re 5 | import sys 6 | 7 | from setuptools.command.easy_install import main 8 | 9 | if __name__ == '__main__': 10 | sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0]) 11 | sys.exit(main()) 12 | -------------------------------------------------------------------------------- /Chapter07/codes/sobel.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread("image.jpg") 3 | gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 4 | x_edges = cv2.Sobel(gray,-1,1,0,ksize=5) 5 | cv2.imwrite("sobel_edges_x.jpg", x_edges) 6 | y_edges = cv2.Sobel(gray,-1,0,1,ksize=5) 7 | cv2.imwrite("sobel_edges_y.jpg", y_edges) 8 | cv2.imshow("xedges", x_edges) 9 | cv2.imshow("yedges", y_edges) 10 | -------------------------------------------------------------------------------- /Chapter07/codes/contours.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread('image.jpg') 3 | gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 4 | thresh_img = cv2.threshold(gray,127,255,0) 5 | im, contours, hierarchy = cv2.findContours(thresh_img[1],cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) 6 | cv2.drawContours(img, contours, -1, (255,0,0), 3) 7 | cv2.imwrite("contours.jpg", img) 8 | cv2.imshow("contours", img) -------------------------------------------------------------------------------- /Chapter07/codes/contour.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | img = cv2.imread('image.jpg') 3 | gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) 4 | thresh_img = cv2.threshold(gray,127,255,0) 5 | im, contours, hierarchy = cv2.findContours(thresh_img[1],cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) 6 | cv2.drawContours(img, contours, -1, (255,0,0), 3) 7 | cv2.imwrite("contours.jpg", img) 8 | cv2.imshow("contours", img) 9 | -------------------------------------------------------------------------------- /Chapter01/codes/skimage_draw_polygon_image.py: -------------------------------------------------------------------------------- 1 | #Program to draw a polygon on an image 2 | 3 | import numpy as np 4 | from skimage import io, draw 5 | 6 | #Make an empty(blank) image 7 | img = np.zeros((100, 100), dtype=np.uint8) 8 | r = np.array([10, 25, 80, 50]) 9 | c = np.array([10, 60, 40, 10]) 10 | x, y = polygon(r, c) 11 | img[x, y] = 1 12 | 13 | 14 | io.imshow(img) 15 | io.show() 16 | -------------------------------------------------------------------------------- /Chapter08/codes/gray.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | cam = cv2.VideoCapture('/Users/salil/Downloads/VID_20170701_160759.mp4') 4 | 5 | while (cam.isOpened()): 6 | 7 | ret, frame = cam.read() 8 | frame = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5) 9 | gray_frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) 10 | cv2.imshow('gray_frame',gray_frame) 11 | cv2.imshow('original_frame',frame) 12 | 13 | if cv2.waitKey(1) & 0xFF == ord('q'): 14 | break 15 | 16 | cam.release() 17 | cv2.destroyAllWindows() 18 | -------------------------------------------------------------------------------- /Chapter04/CODES/superpixels.py: -------------------------------------------------------------------------------- 1 | from skimage import segmentation, color 2 | from skimage.io import imread 3 | from skimage.future import graph 4 | from matplotlib import pyplot as plt 5 | 6 | img = imread('test.jpeg') 7 | 8 | img_segments = segmentation.slic(img, compactness=20, n_segments=500) 9 | superpixels = color.label2rgb(img_segments, img, kind='avg') 10 | 11 | fig, ax = plt.subplots(nrows=1, ncols=2, sharex=True, sharey=True, figsize=(6, 8)) 12 | 13 | ax[0].imshow(img) 14 | ax[1].imshow(superpixels) 15 | 16 | for a in ax: 17 | a.axis('off') 18 | 19 | plt.tight_layout() 20 | plt.show() 21 | -------------------------------------------------------------------------------- /Chapter02/codes/harris.py: -------------------------------------------------------------------------------- 1 | from matplotlib import pyplot as plt 2 | 3 | from skimage import data, io 4 | from skimage.feature import corner_harris, corner_subpix, corner_peaks 5 | 6 | img = io.imread('image.png') 7 | coords = corner_peaks(corner_harris(image), min_distance=5) 8 | coords_subpix = corner_subpix(image, coords, window_size=13) 9 | 10 | fig, ax = plt.subplots() 11 | ax.imshow(image, interpolation='nearest', cmap=plt.cm.gray) 12 | ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3) 13 | ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) 14 | ax.axis((0, 350, 350, 0)) 15 | plt.show() 16 | -------------------------------------------------------------------------------- /Chapter02/codes/hough_lines.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | from skimage.transform import (hough_line, probabilistic_hough_line) 4 | from skimage.feature import canny 5 | 6 | #Read an image 7 | image = io.imread('image.png') 8 | 9 | #Apply your favorite edge detection algorithm. We use 'canny' for this example. 10 | edges = canny(image, 2, 1, 25) 11 | 12 | #Once you have the edges, run the hough transform over the image 13 | lines = hough_lines(image) 14 | probabilistic_lines = probabilistic_hough_line(edges, threshold=10, line_length=5, line_gap=3) 15 | 16 | #As an exercise you can compare the results of both the methods. 17 | -------------------------------------------------------------------------------- /Chapter10/codes/face_detection.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | 4 | face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') 5 | eye_cascade = cv2.CascadeClassifier('haarcascade_eye.xml') 6 | 7 | img = cv2.imread('image.jpg') 8 | img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) 9 | 10 | faces = face_cascade.detectMultiScale(img_gray, 1.3, 5) 11 | 12 | 13 | for (x,y,w,h) in faces: 14 | cv2.rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) 15 | roi_gray = img_gray[y:y+h, x:x+w] 16 | roi_color = img[y:y+h, x:x+w] 17 | eyes = eye_cascade.detectMultiScale(roi_gray) 18 | for (ex,ey,ew,eh) in eyes: 19 | cv2.rectangle(roi_color,(ex,ey),(ex+ew,ey+eh),(0,255,0),2) 20 | 21 | cv2.imwrite('output.jpg',img) 22 | -------------------------------------------------------------------------------- /Chapter04/CODES/contours.py: -------------------------------------------------------------------------------- 1 | from skimage import measure 2 | from skimage.io import imread 3 | from skimage.color import rgb2gray 4 | from skimage.filters import sobel 5 | import matplotlib.pyplot as plt 6 | 7 | #Read an image 8 | img = imread('contours.png') 9 | 10 | #Convert the image to grayscale 11 | img_gray = rgb2gray(img) 12 | 13 | #Find edges in the image 14 | img_edges = sobel(img_gray) 15 | 16 | #Find contours in the image 17 | contours = measure.find_contours(img_edges, 0.2) 18 | 19 | # Display the image and plot all contours found 20 | fig, ax = plt.subplots() 21 | ax.imshow(img_edges, interpolation='nearest', cmap=plt.cm.gray) 22 | 23 | for n, contour in enumerate(contours): 24 | ax.plot(contour[:, 1], contour[:, 0], linewidth=2) 25 | 26 | ax.axis('image') 27 | ax.set_xticks([]) 28 | ax.set_yticks([]) 29 | plt.show() 30 | -------------------------------------------------------------------------------- /Chapter02/codes/thresholding.py: -------------------------------------------------------------------------------- 1 | import matplotlib.pyplot as plt 2 | 3 | from skimage import data 4 | from skimage.filters import threshold_otsu, threshold_local 5 | from skimage.io import imread 6 | from skimage.color import rgb2gray 7 | 8 | image = imread('image.jpg') 9 | image = rgb2gray(image) 10 | 11 | global_thresh = threshold_otsu(image) 12 | binary_global = image > global_thresh 13 | 14 | block_size = 35 15 | binary_adaptive = threshold_local(image, block_size, offset=10) 16 | 17 | fig, axes = plt.subplots(nrows=3, figsize=(7, 8)) 18 | ax0, ax1, ax2 = axes 19 | plt.gray() 20 | 21 | ax0.imshow(image) 22 | ax0.set_title('Image') 23 | 24 | ax1.imshow(binary_global) 25 | ax1.set_title('Global thresholding') 26 | 27 | ax2.imshow(binary_adaptive) 28 | ax2.set_title('Adaptive thresholding') 29 | 30 | for ax in axes: 31 | ax.axis('off') 32 | 33 | plt.show() 34 | 35 | -------------------------------------------------------------------------------- /Chapter05/codes/SVM.py: -------------------------------------------------------------------------------- 1 | from sklearn import datasets, metrics, svm 2 | 3 | mnist = datasets.load_digits() 4 | 5 | images = mnist.images 6 | 7 | data_size = len(images) 8 | 9 | #Preprocessing images 10 | images = images.reshape(len(images), -1) 11 | labels = mnist.target 12 | 13 | #Initialize Logistic Regression 14 | SVM_classifier = svm.SVC(gamma=0.001) 15 | #Training the data on only 75% of the dataset. Rest of the 25% will be used in testing the Logistic Regression 16 | SVM_classifier.fit(images[:int((data_size / 4) * 3)], labels[:int((data_size / 4) * 3)]) 17 | 18 | #Testing the data 19 | predictions = SVM_classifier.predict(images[int((data_size / 4)):]) 20 | target = labels[int((data_size/4)):] 21 | 22 | #Print the performance report of the Logistic Regression model that we learnt 23 | print("Performance Report: \n %s \n" % (metrics.classification_report(target, predictions))) 24 | -------------------------------------------------------------------------------- /Chapter05/codes/pca.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | from itertools import product 4 | from sklearn.decomposition import RandomizedPCA 5 | from sklearn.datasets import fetch_mldata 6 | from sklearn.utils import shuffle 7 | 8 | #use all digits 9 | mnist = fetch_mldata("MNIST original") 10 | X_train, y_train = mnist.data[:70000] / 255., mnist.target[:70000] 11 | 12 | X_train, y_train = shuffle(X_train, y_train) 13 | X_train, y_train = X_train[:5000], y_train[:5000] # lets subsample a bit for a first impression 14 | 15 | pca = RandomizedPCA(n_components=3) 16 | fig, plot = plt.subplots() 17 | fig.set_size_inches(50, 50) 18 | plt.prism() 19 | 20 | X_transformed = pca.fit_transform(X_train) 21 | plot.scatter(X_transformed[:, 0], X_transformed[:, 1], c=y_train) 22 | plot.set_xticks(()) 23 | plot.set_yticks(()) 24 | 25 | #plt.tight_layout() 26 | plt.savefig("mnist_pca.png") 27 | -------------------------------------------------------------------------------- /Chapter10/codes/sift.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import numpy as np 3 | import random 4 | 5 | image = cv2.imread('image.jpg') 6 | image_rot = cv2.imread('image_rot.jpg') 7 | gray= cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) 8 | gray_rot = cv2.cvtColor(image_rot,cv2.COLOR_BGR2GRAY) 9 | 10 | surf = cv2.xfeatures2d.SURF_create() 11 | 12 | kp, desc = surf.detectAndCompute(gray,None) 13 | kp_rot, desc_rot = surf.detectAndCompute(gray_rot, None) 14 | 15 | # BFMatcher with default params 16 | bf = cv2.BFMatcher() 17 | matches = bf.knnMatch(desc,desc_rot, k=2) 18 | 19 | # Apply ratio test 20 | good = [] 21 | for m,n in matches: 22 | if m.distance < 0.4*n.distance: 23 | good.append([m]) 24 | random.shuffle(good) 25 | 26 | # cv2.drawMatchesKnn expects list of lists as matches. 27 | image_match = cv2.drawMatchesKnn(image,kp,image_rot,kp_rot,good[:10],flags=2, outImg=None) 28 | 29 | cv2.imwrite('surf_matches.jpg',image_match) 30 | -------------------------------------------------------------------------------- /Chapter05/codes/KMeans.py: -------------------------------------------------------------------------------- 1 | from sklearn import datasets, metrics 2 | from sklearn.cluster import KMeans 3 | 4 | mnist = datasets.load_digits() 5 | 6 | images = mnist.images 7 | 8 | data_size = len(images) 9 | 10 | #Preprocessing images 11 | images = images.reshape(len(images), -1) 12 | labels = mnist.target 13 | 14 | #Initialize Logistic Regression 15 | clustering = KMeans(n_clusters=10, init='k-means++', n_init=10) 16 | 17 | #Training the data on only 75% of the dataset. Rest of the 25% will be used in testing the KMeans Clustering 18 | clustering.fit(images[:int((data_size / 4) * 3)]) 19 | 20 | #Print the centers of the different clusters 21 | print(clustering.labels_) 22 | 23 | #Testing the data 24 | predictions = clustering.predict(images[int((data_size / 4)):]) 25 | target = labels[int((data_size/4)):] 26 | 27 | #Print the performance report of the Logistic Regression model that we learnt 28 | print("Performance Report: \n %s \n" % (metrics.classification_report(target, predictions))) 29 | -------------------------------------------------------------------------------- /Chapter03/code/harris.py: -------------------------------------------------------------------------------- 1 | from matplotlib import pyplot as plt 2 | from skimage.io import imread 3 | from skimage.color import rgb2gray 4 | from skimage.feature import corner_harris, corner_subpix, corner_peaks 5 | 6 | #Read an image 7 | image = imread('test.png') 8 | image = rgb2gray(image) 9 | 10 | #Compute the Harris corners in the image. This returns a corner measure response for each pixel in the image 11 | corners = corner_harris(image) 12 | 13 | #Using the corner response image we calculate the actual corners in the image 14 | coords = corner_peaks(corners, min_distance=5) 15 | 16 | # This function decides if the corner point is an edge point or an isolated peak 17 | coords_subpix = corner_subpix(image, coords, window_size=13) 18 | 19 | fig, ax = plt.subplots() 20 | ax.imshow(image, interpolation='nearest', cmap=plt.cm.gray) 21 | ax.plot(coords[:, 1], coords[:, 0], '.b', markersize=3) 22 | ax.plot(coords_subpix[:, 1], coords_subpix[:, 0], '+r', markersize=15) 23 | ax.axis((0, 350, 350, 0)) 24 | plt.show() 25 | -------------------------------------------------------------------------------- /Chapter05/codes/LR.py: -------------------------------------------------------------------------------- 1 | from sklearn import datasets, metrics 2 | from sklearn.linear_model import LogisticRegression 3 | from sklearn.preprocessing import StandardScaler 4 | 5 | mnist = datasets.load_digits() 6 | 7 | img_tuple = list(zip(mnist.images, mnist.target)) 8 | 9 | images = mnist.images 10 | 11 | data_size = len(images) 12 | 13 | #Preprocessing images 14 | images = images.reshape(len(images), -1) 15 | labels = mnist.target 16 | 17 | #Initialize Logistic Regression 18 | LR_classifier = LogisticRegression(C=0.01, penalty='l1', tol=0.01) 19 | #Training the data on only 75% of the dataset. Rest of the 25% will be used in testing the Logistic Regression 20 | LR_classifier.fit(images[:int((data_size / 4) * 3)], labels[:int((data_size / 4) * 3)]) 21 | 22 | #Testing the data 23 | predictions = LR_classifier.predict(images[int((data_size / 4)):]) 24 | target = labels[int((data_size/4)):] 25 | 26 | #Print the performance report of the Logistic Regression model that we learnt 27 | print("Performance Report: \n %s \n" % (metrics.classification_report(target, predictions))) 28 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Packt 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Chapter06/codes/mlp.py: -------------------------------------------------------------------------------- 1 | from sklearn.datasets import fetch_mldata 2 | from sklearn.neural_network import MLPClassifier 3 | from sklearn.preprocessing import normalize 4 | from sklearn.model_selection import train_test_split 5 | 6 | #Get MNIST Dataset 7 | print('Getting MNIST Data...') 8 | mnist = fetch_mldata('MNIST original') 9 | print('MNIST Data downloaded!') 10 | 11 | images = mnist.data 12 | labels = mnist.target 13 | 14 | #Preprocess the images 15 | images = normalize(images, norm='l2') #You can use l1 norm too 16 | 17 | #Split the data into training set and test set 18 | images_train, images_test, labels_train, labels_test = train_test_split(images, labels, test_size=0.25, random_state=17) 19 | 20 | #Setup the neural network that we want to train on 21 | nn = MLPClassifier(hidden_layer_sizes=(200), max_iter=20, solver='sgd', learning_rate_init=0.001, verbose=True) 22 | 23 | #Start training the network 24 | print('NN Training started...') 25 | nn.fit(images_train, labels_train) 26 | print('NN Training completed!') 27 | 28 | #Evaluate the performance of the neural network on test data 29 | print('Network Performance: %f' % nn.score(images_test, labels_test)) 30 | -------------------------------------------------------------------------------- /Chapter09/Client/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 16 | 17 | 18 | 19 | 20 | 21 |