इस कार्यक्रम में, हम OpenCV लाइब्रेरी में डाइलेट फ़ंक्शन का उपयोग करके एक छवि को फैलाएंगे। Dilation एक छवि में वस्तुओं की सीमाओं में पिक्सेल जोड़ता है, यानी, यह छवि को सभी तरफ फैलाता है।
मूल चित्र

एल्गोरिदम
Step 1: Import cv2 and numpy. Step 2: Read the image using opencv.imread(). Step 3: Define the kernel using np.ones() function. Step 4: Pass the image and kernel to the dilate() function. Step 5: Display the image
उदाहरण कोड
import cv2
import numpy as np
image = cv2.imread('testimage.jpg')
kernel = np.ones((3,3), np.uint8)
image = cv2.dilate(image, kernel)
cv2.imshow('Dilated Image', image) आउटपुट

स्पष्टीकरण
जैसा कि आप देख सकते हैं, छवि का विस्तार किया गया है, यानी, छवि के पिक्सेल विस्तारित हैं और इसलिए, छवि थोड़ी विकृत दिखती है।