[英]How to implement a kernel of size 1 in a Gaussian filter in opencv?
我正在嘗試創建一個1像素內核:
x = cv2.getGaussianKernel(1, 2)
我在高斯濾波器中使用它:
blur = cv2.GaussianBlur(img, x, 0)
結果,發生錯誤:
SystemError: new style getargs format but argument is not a tuple
如何解決這個錯誤?
您不能將內核傳遞給GaussianBlur函數。 您必須傳遞內核大小。
所以x應該是像(5,5)或(3,3)等的元組
同樣,內核大小值應為奇數且為正,並且可以不同。 因為2是偶數,所以不能使用size(1,2)。
如果要查看高斯內核,請使用以下命令:
cv2.getGaussianKernel(ksize, sigma[, ktype])
例如:
kernel = cv2.getGaussianKernel(ksize=(1,1),sigma=2)
如果要使用內核模糊圖像,請使用以下命令:
cv2.GaussianBlur(src, ksize, sigmaX[, dst[, sigmaY[, borderType]]])
例如:
cv2.GaussianBlur(src, ksize=(1,1))
檢查這個
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.