need to extract rgb value of image in the format [r g b]

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.

 Respuesta aceptada

Matt Fig
Matt Fig el 4 de Mayo de 2011
Somehow you don't have the image handle. So try this:
IH = findall(0,'type','image');
IM = getimage(IH);

6 comentarios

Aishwarya
Aishwarya el 4 de Mayo de 2011
still not working. could you please give me alternative code for this
Is it still not working?
Matt Fig
Matt Fig el 4 de Mayo de 2011
Wow, that is one fast mouse click. What does the call to FINDALL return? If it returns [], then I am afraid you don't have an image to pass to GETIMAGE. Are you trying to pass an array to GETIMAGE? Because an array is not an image object. An image object is returned from, for example:
IH = image(A);% Where A is an array.
Aishwarya
Aishwarya el 5 de Mayo de 2011
same image name is iving me results with imread() but fails with getimage..!!!!.can we use imread() to give results like [r g b] value in a simple vector matrix. because it is showing results in te format of m x n x 3.
Matt Fig
Matt Fig el 5 de Mayo de 2011
Ahh, but that is the problem!
It sounds like you are passing a filename to GETIMAGE, which is not correct. GETIMAGE takes a handle to an image object, not an image filename. Here I will make an example which shows what each function returns.
Image_data = imread('myimage.jpg'); % For example
Image_handle = image(Image_data); % Or IMSHOW
Image_info = getimage(Image_handle);
Aishwarya
Aishwarya el 6 de Mayo de 2011
thank you it really helped.

Iniciar sesión para comentar.

Más respuestas (1)

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 comentario

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.

Iniciar sesión para comentar.

Categorías

Más información sobre Convert Image Type en Centro de ayuda y File Exchange.

Preguntada:

el 4 de Mayo de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by