Ask Your Question
0

CV_8UC3 returns grayscale

asked 2016-08-29 10:01:44 -0600

kuntoro gravatar image

Excuse me, I'm new to opencv. I learned about CV_8UC3 that it defines an image in 8 bit unsigned integers using 3 channels (BGR). When a color image is loaded using this constant as parameter,

cv::Mat image = cv::imread("image_file.jpg", CV_8UC3);

does that mean that it instructs to load the image as color image? I tried that to load and display using cv::namedWindow, as a result, the image is displayed in grayscale instead. But when the parameter CV_8UC3 is removed, the color image is loaded and displayed normally (as color image). Do I misunderstand the concept or is there (probably) a bug in my code?

Thank you very much. (I'm sorry if my English is not good)

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2016-08-29 10:07:57 -0600

berak gravatar image

updated 2016-08-29 10:08:36 -0600

CV_8UC3 is simply the wrong flag here, please use one of the IMREAD_XXX flags instead, like:

cv::Mat image = cv::imread("image_file.jpg", cv::IMREAD_COLOR);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-29 10:01:44 -0600

Seen: 2,507 times

Last updated: Aug 29 '16