MATLAB Answers

error while using rgb2gray

3 views (last 30 days)
???Error using ==>rgb2gray>parse_inputs at 82 MAP must be a m*3 array.
Error in ==>rgb2gray at 35 X=parse_inputs(varargin{:});
Error in ==>match at 167 im1=(double(rgb2gray(I)));
Can anyone please tell me why rgb2gray is showing problem.And what is meaning of error.

  2 Comments

Ryan
Ryan on 31 Jul 2012
What class/size is I?
matlab_image
matlab_image on 31 Jul 2012
Thanks dear but the problem got solved by changing I to Img.

Sign in to comment.

Accepted Answer

Image Analyst
Image Analyst on 31 Jul 2012
First of all, pick a different name than I. I looks too much like 1 and l. Maybe use rgbImage. Then say "whos I" on the command line and see what it says. Also, you don't need the parentheses around the double() command. So you can do something like
whos rgbImage
size(rgbImage)
doubleRGBImage = double(rgb2gray(rgbImage));
If you still can't figure it out, come back here and tell us what else you learned. My guess is that your I is not a normal color image with 3 color channels.

  1 Comment

matlab_image
matlab_image on 31 Jul 2012
Thanks a lot Image Analyst. I have just changed I to Img and now it works. Thanks again.

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Products