From 94699ba4a49e17f813666557037cb37cead9d236 Mon Sep 17 00:00:00 2001 From: Fariz Rahman Date: Mon, 1 May 2017 01:38:51 +0530 Subject: [PATCH 1/3] Display images on readme --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9ecce03..265899f 100644 --- a/README.md +++ b/README.md @@ -46,6 +46,7 @@ Instead of manually constructing the translation matrix *M* and calling `cv2.war translated = imutils.translate(workspace, 25, -75) #### Output: + Translation example ## Rotation @@ -59,6 +60,7 @@ for angle in xrange(0, 360, 90): cv2.imshow("Angle=%d" % (angle), rotated) #### Output: + Rotation example ## Resizing @@ -74,6 +76,7 @@ for width in (400, 300, 200, 100): cv2.imshow("Width=%dpx" % (width), resized) #### Output: + Resizing example ## Skeletonization @@ -90,6 +93,7 @@ skeleton = imutils.skeletonize(gray, size=(3, 3)) cv2.imshow("Skeleton", skeleton) #### Output: + Skeletonization example ## Displaying with Matplotlib @@ -106,6 +110,7 @@ plt.imshow(imutils.opencv2matplotlib(cactus)) plt.show() #### Output: + Matplotlib example ## URL to Image @@ -118,6 +123,7 @@ cv2.imshow("URL to Image", logo) cv2.waitKey(0) #### Output: + Matplotlib example ## Checking OpenCV Versions @@ -143,6 +149,7 @@ cv2.imshow("Original", logo) cv2.imshow("Automatic Edge Map", edgeMap) #### Output: + Matplotlib example ## 4-point Perspective Transform @@ -152,6 +159,7 @@ A common task in computer vision and image processing is to perform a 4-point pe See the contents of `demos/perspective_transform.py` #### Output: + Matplotlib example ## Sorting Contours @@ -161,6 +169,7 @@ The contours returned from `cv2.findContours` are unsorted. By using the `contou See the contents of `demos/sorting_contours.py` #### Output: + Matplotlib example ## (Recursively) Listing Paths to Images @@ -179,4 +188,4 @@ for imagePath in paths.list_images("../demo_images"): ../demo_images/notecard.png ../demo_images/pyimagesearch_logo.jpg ../demo_images/shapes.png -../demo_images/workspace.jpg \ No newline at end of file +../demo_images/workspace.jpg From 554bce975e802d3a3fd58fbcdc3c77b718ce19b1 Mon Sep 17 00:00:00 2001 From: Fariz Rahman Date: Mon, 1 May 2017 01:41:44 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 265899f..d88a6cb 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ translated = imutils.translate(workspace, 25, -75) #### Output: -Translation example +Translation example ## Rotation Rotating an image in OpenCV is accomplished by making a call to `cv2.getRotationMatrix2D` and `cv2.warpAffine`. Further care has to be taken to supply the *(x, y)*-coordinate of the point the image is to be rotated about. These calculation calls can quickly add up and make your code bulky and less readable. The `rotate` function in `imutils` helps resolve this problem. From 9e47e646800a473d7dca993172cb41a7330e54fc Mon Sep 17 00:00:00 2001 From: Fariz Rahman Date: Mon, 1 May 2017 01:42:41 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d88a6cb..5d3f251 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ for angle in xrange(0, 360, 90): #### Output: -Rotation example +Rotation example ## Resizing Resizing an image in OpenCV is accomplished by calling the `cv2.resize` function. However, special care needs to be taken to ensure that the aspect ratio is maintained. This `resize` function of `imutils` maintains the aspect ratio and provides the keyword arguments `width` and `height` so the image can be resized to the intended width/height while (1) maintaining aspect ratio and (2) ensuring the dimensions of the image do not have to be explicitly computed by the developer. @@ -77,7 +77,7 @@ for width in (400, 300, 200, 100): #### Output: -Resizing example +Resizing example ## Skeletonization Skeletonization is the process of constructing the "topological skeleton" of an object in an image, where the object is presumed to be white on a black background. OpenCV does not provide a function to explicitly construct the skeleton, but does provide the morphological and binary functions to do so. @@ -94,7 +94,7 @@ cv2.imshow("Skeleton", skeleton) #### Output: -Skeletonization example +Skeletonization example ## Displaying with Matplotlib In the Python bindings of OpenCV, images are represented as NumPy arrays in BGR order. This works fine when using the `cv2.imshow` function. However, if you intend on using Matplotlib, the `plt.imshow` function assumes the image is in RGB order. A simple call to `cv2.cvtColor` will resolve this problem, or you can use the `opencv2matplotlib` convenience function. @@ -111,7 +111,7 @@ plt.show() #### Output: -Matplotlib example +Matplotlib example ## URL to Image This the `url_to_image` function accepts a single parameter: the `url` of the image we want to download and convert to a NumPy array in OpenCV format. This function performs the download in-memory. The `url_to_image` function has been detailed [here](http://www.pyimagesearch.com/2015/03/02/convert-url-to-image-with-python-and-opencv/) on the PyImageSearch blog. @@ -124,7 +124,7 @@ cv2.waitKey(0) #### Output: -Matplotlib example +Matplotlib example ## Checking OpenCV Versions OpenCV 3 has finally been released! But with the major release becomes backward compatibility issues (such as with the `cv2.findContours` and `cv2.normalize` functions). If you want your OpenCV 3 code to be backwards compatible with OpenCV 2.4.X, you'll need to take special care to check which version of OpenCV is currently being used and then take appropriate action. The `is_cv2()` and `is_cv3()` are simple functions that can be used to automatically determine the OpenCV version of the current environment. @@ -150,7 +150,7 @@ cv2.imshow("Automatic Edge Map", edgeMap) #### Output: -Matplotlib example +Matplotlib example ## 4-point Perspective Transform A common task in computer vision and image processing is to perform a 4-point perspective transform of a ROI in an image and obtain a top-down, "birds eye view" of the ROI. The `perspective` module takes care of this for you. A real-world example of applying a 4-point perspective transform can be bound in this blog on on [building a kick-ass mobile document scanner](http://www.pyimagesearch.com/2014/09/01/build-kick-ass-mobile-document-scanner-just-5-minutes/). @@ -160,7 +160,7 @@ See the contents of `demos/perspective_transform.py` #### Output: -Matplotlib example +Matplotlib example ## Sorting Contours The contours returned from `cv2.findContours` are unsorted. By using the `contours` module the the `sort_contours` function we can sort a list of contours from left-to-right, right-to-left, top-to-bottom, and bottom-to-top, respectively. @@ -170,7 +170,7 @@ See the contents of `demos/sorting_contours.py` #### Output: -Matplotlib example +Matplotlib example ## (Recursively) Listing Paths to Images The `paths` sub-module of `imutils` includes a function to recursively find images based on a root directory.