Then I display it with imagesc and colormap HSV: imagesc(A); colormap(hsv);
Is there any way now (without using Image processing Toolbox) to save to a matrix the R,G,B triplets corresponding to the colors of each pixel as produced using HSV?
You need to figure out how to map that to the colormap. When the number of unique values in the image is less than the length of the map; it will index directly, i.e. 1 will be the first element, 2 will be the second.
When you have more unique elements - say uint16 image where you can have integer values of 65535 and you're map is only 256 elements or 64 elements or however many elements, then you need to figure out how they scale. That's what I attempted do with histc. You copuld always just make a colomap contain as many values as you ave unique in your image. For a uint8 image this is trivial map = hsv(256) and the pixel values will line up with an offset of 1, i.e. 0->1st row of map; 1->2nd row of map;255->256th row of map)
When you have an indexed image, getting the CData of it is going to return the indexes, not the color it is mapped to. You need to convert the indexes in to color values. The freezeColors routine from the FEX sets the CData to the color values, and Sean's routine calculates the color values without going through CData, but the block of code you show here will just return the original indices.
The example in my original question was a simple one, and with a reference to Steve's blog, so it was perfect to explain what I wanted to do (I often tent to be a bit vague, typical of non native speakers).
Sean, usually my images would have more than 256 elements, so I will have to look into the suggested method more carefully as I'm not familiar with either histc or numel.
With one of the maps I had in mind I was trying to get to the RGB colors after the application of an overlay with alpha as in this other post by Steve: http://blogs.mathworks.com/steve/2009/02/18/image-overlay-using-transparency/ . Walter's idea of using freezeColors worked in that case too, with a slight adaptation. I'm about to post an example on my blog and I will acknowledge the answer, then post it on this thread.
No se puede completar la acción debido a los cambios realizados en la página. Vuelva a cargar la página para ver el estado actualizado.
Translated by
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.