使用 OpenCV 提升影像的取樣率


在本程式中,我們將提升影像的取樣率。提升取樣率是指在保持影像的二維表示時增加空間解析度。它通常用於放大影像上的小區域。我們將使用 openCV 庫中的 pyrup() 函式來完成此任務。

原圖

演算法

Step 1: Read the image.
Step 2: Pass the image as a parameter to the pyrup() function.
Step 3: Display the output.

示例程式碼

import cv2

image = cv2.imread('testimage.jpg')
print("Size of image before pyrUp: ", image.shape)

image = cv2.pyrUp(image)
print("Size of image after pyrUp: ", image.shape)
cv2.imshow('UpSample', image)

輸出

Size of image before pyrUp: (350, 700, 3)
Size of image after pyrUp: (700, 1400, 3)

說明

如果我們在使用 pyrUp 函式之前和之後觀察影像的大小,我們會發現大小增加了,即我們提升了影像的取樣率。

更新日期:2021-03-17

4K+ 次瀏覽

開啟你的 職業生涯

完成課程後獲得認證

開始
廣告