image reading error [closed]

asked 2017-03-26 14:37:14 -0600

error: ........\opencv\modules\imgproc\src\color.cpp:3739: error: (-215) scn == 3 || scn == 4 in function cv::cvtColor

Help me out.

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-09-16 17:06:01.241979

Comments

This is not a problem in image reading. You are calling cvtColor with a conversion type that expects 3 or 4 channel input, and the image you give it is not 3 or 4 channels.

Tetragramm gravatar imageTetragramm ( 2017-03-26 17:23:22 -0600 )edit

you are talking about RGBA channels is it? if images are storing into jpg format we will get only 3 channels, there were some different images into jpg i tried that to.., please give me some solution..

idealvijay gravatar imageidealvijay ( 2017-03-28 01:28:05 -0600 )edit

RGB would be 3, RGBA would be 4. Either should work Just after your imread(), call image.channels() to get the number of channels it has. If it's grayscale, you'll only have 1.

Tetragramm gravatar imageTetragramm ( 2017-03-28 17:19:23 -0600 )edit