O'Reilly logo

Computer Vision with Python 3 by Saurabh Kapur

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dilation

Similarly, let's see the code for dilation using the dilate() function:

>>> import cv2>>> import numpy as np>>> img = cv2.imread("thresholding.jpg")>>> ker = np.ones((5,5),np.uint8)>>> new_img = cv2.dilate(img,ker,iterations = 1)>>> cv2.imwrite("dilation.jpg", new_img)>>> cv2.imshow("dilation", new_img)

The following figure is the output of the preceding code:

Figure 12: The input image is on the left and the image on the right is the output

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required