how to convert image to rgb image to grayscale?

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Guillaume
Guillaume il 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.
monica sabharwal
monica sabharwal il 15 Feb 2016
no... i have resized it through paint

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 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 Commenti
monica sabharwal
monica sabharwal il 15 Feb 2016
Modificato: Walter Roberson il 15 Feb 2016
for (512X512)
[rows, columns, numberOfColorChannels] = size('1.jpg') giving result 1,9,1
for(103X103)
[rows, columns, numberOfColorChannels] = size('1.jpg') giving result 1,5,1)
Walter Roberson
Walter Roberson il 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.

Accedi per commentare.

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by