need to extract rgb value of image in the format [r g b]
Afficher commentaires plus anciens
i need to extract rgb value of any image in the format of [R G B]. I am using getimage() but I am getting error
??? Error using ==> getimage>parseInputs at 217 GETIMAGE: Invalid handle H.
Error in ==> getimage at 86 him = parseInputs(varargin{:});
please suggest.
Réponse acceptée
Plus de réponses (1)
Teja Muppirala
le 5 Mai 2011
If you have a RGB image that is [m x n x 3], you can use the RESHAPE command to give you the columns as [r g b]:
I = imread('peppers.png'); % Read in a sample image
size(I)
I2 = reshape(I,[],3);
size(I2)
Now I2 is of the form [R G B] and has size [(m x n) 3]
1 commentaire
Teja Muppirala
le 5 Mai 2011
By the way, when you were using GETIMAGE, where you perhaps trying to do something like this?
getimage('somefile.jpg')
This is not correct. The GETIMAGE command is not for reading in files, and so you will get an error if you try this. As you stated, IMREAD is the correct command.
Catégories
En savoir plus sur Convert Image Type dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!