使用 OpenCV 降采样图像
在本程序中,我们将对图像进行下采样。下采样是降低空间分辨率但保留图像的 2D 表示。通常用于缩小图像。我们将使用 openCV 库中的 pyrdown() 函数来完成此任务。
原始图像

算法
Step 1: Fead the image. Step 2: Pass the image as a parameter to the pyrdown() function. Step 3: Display the output.
示例代码
import cv2
image = cv2.imread('testimage.jpg')
print("Size of image before pyrDown: ", image.shape)
image = cv2.pyrDown(image)
print("Size of image after pyrDown: ", image.shape)
cv2.imshow('DownSample', image)输出
Size of image before pyrDown: (350, 700, 3) Size of image after pyrDown: (175, 350, 3)

说明
如果我们观察在使用 pyrDown 函数之前和之后图像的大小,会发现大小减小,即我们对图像进行了下采样。
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP