Ask Your Question
1

A simple question on cvtColor

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

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
3

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

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
0

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

unxnut gravatar image

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

edit flag offensive delete link more

Question Tools

Stats

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

Seen: 595 times

Last updated: Apr 22 '13