利用 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