使用下面的代码尝试去噪一个非常简单的图像。当打印出数据数组时,我得到以下结构,这是预期的,因为图像是灰度的:
[[ 62 62 63 ... 29 16 6]
[ 75 90 103 ... 21 16 12]
[ 77 100 118 ... 29 29 30]
...
[ 84 68 56 ... 47 50 53]
[101 94 89 ... 40 44 48]
这是代码和相关的错误,这时我有点卡住了。有什么建议?
import cv2
from matplotlib import pyplot as plt
img = cv2.imread(path,0)
dst = cv2.fastNlMeansDenoising(img,None,10,10,7,21)
plt.subplot(211),plt.imshow(dst)
plt.subplot(212),plt.imshow(img)
plt.show()
____________________________________________________________________
runfile(___, wdir='G:/James Alexander/Python Programs')
Traceback (most recent call last):
File "<ipython-input-127-ce832752c183>", line 1, in <module>
runfile('G:/James Alexander/Python Programs/Noiseremoval.py', wdir=___)
File "___", line 704, in runfile
execfile(filename, namespace)
File "___", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "___", line 13, in <module>
dst = cv2.fastNlMeansDenoising(img,None,10,10,7,21)
error: OpenCV(4.1.0) C:\projects\opencv-python\opencv\modules\photo\src\denoising.cpp:120: error: (-215:Assertion failed) hn == 1 || hn == cn in function 'cv::fastNlMeansDenoising'
阅读有关正在使用的降噪功能的文档。调用该函数有两种方法,您似乎正在将两者结合起来。
dst = cv.fastNlMeansDenoising(src[, dst[, h[, templateWindowSize[, searchWindowSize]]]])
要么
dst = cv.fastNlMeansDenoising(src, h[, dst[, templateWindowSize[, searchWindowSize[, normType]]]])
您正在调用它时,(src, dst, h, templateWindowSize, searchWindowSize, normType)
它使用的参数过多或顺序错误,这取决于要使用的方法。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句