利用 OpenCV 函式 dilate()擴充套件影像
本程式使用 OpenCV 庫中的擴充套件函式,擴充套件影像。擴充套件會在影像中的物件邊界中新增畫素,即影像的各個側面都會擴充套件。
原始影像

演算法
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)輸出

說明
正如你看到的,影像擴充套件了,即影像中的畫素擴充套件了,所以影像看起來有些變形。
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP