Save pixel color value for indexed image (without image Processing Toolobx)

4 views (last 30 days)
With reference to Steve Eddins blog post on pixel colors:
Suppose I create his same image: A = magic(5);
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?
Thanks, Matteo
  1 Comment
Matteo Niccoli
Matteo Niccoli on 8 Feb 2012
Thanks Walter and Sean.
It will take me some time but i will try both suggestions and then will comment on results.

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 8 Feb 2012
apply that routine and then get() the CData property and that will be the RGB.
Matteo Niccoli
Matteo Niccoli on 9 Apr 2012
Hi Walter
Here's my blog post showing what I am doing (I used your suggestion and applied to color with shading)
Thanks again. And thanks to Sean as well.

Sign in to comment.

More Answers (1)

Sean de Wolski
Sean de Wolski on 8 Feb 2012
Something like:
A = magic(5);
map = hsv;
Av = A(:);
[~, bin] = histc(Av,linspace(min(Av),max(Av),min(numel(Av),size(map,1))));
mapp = permute(map,[1 3 2]);
rgb = reshape(mapp(bin,:,:),size(A,1),size(A,2),3);

Sign in to comment.


Find more on Colormaps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!