Ask Your Question

A simple question on cvtColor

asked 2013-04-22 15:36:01 -0500

hayden gravatar image

Hello Every body, I have a simple question. If the image is already grey scale image, do I still need to use cvtColor(img, gray, CV_BGR2GRAY) for further processing?

Thanks in advance.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted

answered 2013-04-22 15:51:58 -0500

berak gravatar image

in general, no.

but beware, the default flag for imread(img_path, flag) is CV_LOAD_IMAGE_COLOR(==1), so that would leave you with 3 identical channels, even if your img is 1-channel gray on disk.

to avoid that problem, call imread(path, CV_LOAD_IMAGE_GRAYSCALE) // or 0 for the flag

if you want a 1-channel img here

edit flag offensive delete link more

answered 2013-04-22 15:49:33 -0500

unxnut gravatar image

No, you do not need to convert a grayscale image.

edit flag offensive delete link more

Question Tools


Asked: 2013-04-22 15:36:01 -0500

Seen: 363 times

Last updated: Apr 22 '13