I wrote a simple opencv program, which reduce the noise of images.
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()
horse.png
When I ran the program it gave an error. Which is...
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
How should I over come this?
you need to convert the image like this:
converted_img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
A little late to help you, but I hope it helps someone.
Cheers!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With