Opencv-python: Type of input image should be CV_8UC3 or CV_8UC4! in function fastNlMeansDenoisingColored
11,647
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!
Comments
-
Govinda Malavipathirana almost 2 years
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()
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?
-
user288609 over 4 yearsHi, I tried your suggestions, and I got the following error, error: OpenCV(4.1.1) ..\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'
-
Gleidson Cardoso da Silva over 4 yearsHi, this error happens to me when the image file does not exist or I can't open it.