how to convert image to rgb image to grayscale?
2 views (last 30 days)
Show older comments
When using code mentioned in matlab examples, its working fine on 103X103 image but when applying same code on 512X512 image showing following error message. ??? Error using ==> rgb2gray>parse_inputs at 82 MAP must be a m x 3 array.
Error in ==> rgb2gray at 35 X = parse_inputs(varargin{:});
2 Comments
Guillaume
on 14 Feb 2016
"i have just resized the 512x512 image to 103x103."
Yoy may have made a mistake in the way you resize the image. Post your code that does the resizing as well as the part with the rgb2gray call.
To post your code, just paste in a comment then click on the {}Code button to format it properly.
Answers (1)
Star Strider
on 14 Feb 2016
It must already be a grayscale image, or an image with only one channel. The rgb3gray documentation says the input image has to be a truecolour 3D numeric array.
5 Comments
Walter Roberson
on 15 Feb 2016
IM512 = imread('1.jpg'); %read the 512 x 512 image
[rows, columns, numberOfColorChannels] = size(IM512)
IM103 = imread('1.jpg'); %read the 103 x 103 image
[rows, columns, numberOfColorChannels] = size(IM103)
You cannot use rgb2gray on an image name, you have to use it on the content of an image.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!