How do you know if an image is rgb?
rgb - Determine whether an image is Grayscale in Matlab - Stack Overflow
· chat blog
· Meta Stack Overflow
· Careers 2.0
-more stack exchange communities-
sign up log in tour help
· Tour Start here for a quick overview of the site
· Help Center Detailed answers to any questions you might have
· Meta Discuss the workings and policies of this site
· Ask Question
Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and
enthusiast programmers. It's 100% free, no registration required.
** Determine whether an image is Grayscale in Matlab **
up vote down vote favorite
I'm writing a function which can take an image and perform specific
smoothing tasks on. At the very beginning of my function I convert the
image to a grayscale image using pic = rgb2gray(pic);
I'm hoping to allow the function to take any image (even if its already
grayscale). In Matlab, if I pass it a grayscale image it currently errors
because it cannot convert it (which is obvious).
Is there a built in function or an easy way to test an image and determine
its colour format?
I read on google something about isRGB and isGrayscale functions but they
have been removed from later versions of Matlab...
I'm thinking something like this would be cool if it had a built in
if (pic == RGB)
elseif (pic == GrayScale)
If not, maybe I could write a function that takes a pixel x,y and tests its
if (p(x,y) == .... or something? I'm unsure... Thoughts?
matlab rgb grayscale
share|improve this question
asked Feb 13
© 2005-2018 HaveYourSay.org