使用 OpenCV 函式 erode() 侵蝕影像
在本程式中,我們將使用 OpenCV 函式 erode() 侵蝕影像。影像侵蝕是指縮小影像。如果核中的任何畫素為 0,則核中的所有畫素都將設為 0。在對影像應用侵蝕函式之前有一個條件,即影像應為灰度影像。
原始影像

演算法
Step 1: Import cv2 Step 2: Import numpy. Step 3: Read the image using imread(). Step 4: Define the kernel size using numpy ones. Step 5: Pass the image and kernel to the erode function. Step 6: Display the output.
示例程式碼
import cv2
import numpy as np
image = cv2.imread('testimage.jpg')
kernel = np.ones((7,7), np.uint8)
image = cv2.erode(image, kernel)
cv2.imshow('Eroded Image', image)輸出

廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP