我写了一个简单的opencv程序,可以降低图像的噪声。
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('stream/horse.png')
dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 21)
cv2.imshow(dst)
plt.subplot(121), plt.imshow(img)
plt.subplot(122), plt.imshow(dst)
plt.show()
当我运行程序时出现错误。这是...
OpenCV Error: Bad argument (Type of input image should be CV_8UC3 or CV_8UC4!) in fastNlMeansDenoisingColored, file /home/govinda/github_repos/opencv/modules/photo/src/denoising.cpp, line 176
Traceback (most recent call last):
File "/home/govinda/workspace-python/opencv/src/Smle.py", line 7, in <module>
dst = cv2.fastNlMeansDenoisingColored(img, None, 10, 10, 7, 21)
cv2.error: /home/govinda/github_repos/opencv/modules/photo/src/denoising.cpp:176: error: (-5) Type of input image should be CV_8UC3 or CV_8UC4! in function fastNlMeansDenoisingColored
我该如何克服呢?
最佳答案
你需要像这样转换图像:
converted_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
帮助你有点晚了,但我希望它能帮助别人。
干杯!
关于python - 函数 fastNlMeansDenoisingColored 中的 Opencv-python : Type of input image should be CV_8UC3 or CV_8UC4!,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44601593/