First time here? Check out the FAQ!

Ask Your Question
1

A simple question on cvtColor

asked Apr 22 '13

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.

Preview: (hide)

2 answers

Sort by » oldest newest most voted
3

answered Apr 22 '13

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

Preview: (hide)
0

answered Apr 22 '13

unxnut gravatar image

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

Preview: (hide)

Question Tools

Stats

Asked: Apr 22 '13

Seen: 623 times

Last updated: Apr 22 '13