Hi i need a solution for this...while loading some of the CT images,i am getting an error like this....plz help me

1 view (last 30 days)
Error using rgb2gray>parse_inputs (line 81) MAP must be a m x 3 array.
Error in rgb2gray (line 35) X = parse_inputs(varargin{:});
Error in Untitled6 (line 8) I = rgb2gray(rgb);
  2 Comments
Sivakumaran Chandrasekaran
the input which you given is a gray image. since the input is itself a gray image already, you cant convert it to gray image.
if you use color image as input, you will not get this error
Walter Roberson
Walter Roberson on 25 Dec 2015
That is possible, that the image is already grayscale. In my experience it is more likely that the image is an indexed image that has not been read properly, as people tend to forget about that possibility when they write their code.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 23 Dec 2015
Your image is not an rgb image, it is an indexed image. You need to read the color map when you read the image and use ind2gray
[non_rgb, map] = imread('YourFile.bmp');
I = ind2gray(non_rgb, map);

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!