Problem with colorbar and values of scale

16 views (last 30 days)
Haimon
Haimon on 8 May 2014
Commented: Image Analyst on 3 Jun 2014
I have this image in HSV colorbar, regarding a density parameter.
Values range from 0 (air) to a maximum of 10, which was my prerrogative (it only goes up to 7.5 though).
What I want to know is why the scale starts at 0.5, and not 0? Air we consider of zero density (although it is not true, for interaction with X-rays we can consider it so)
Before someone asks, I already verified the matrix of the density variable and there is zeros around the sample, which appears in the image.
My code below:
figure;
image(rho);
colormap(hsv(ceil(rhomax-rhomin)));
cbh = colorbar('location', 'SouthOutside');
set(cbh, 'Units', 'normal', 'Xtick',0:0.5:10); %(I thought this part would make the values start from 0)
text(3.5, -1, 'Densidade (g/cm³)', 'Parent', cbh);

Answers (1)

Image Analyst
Image Analyst on 8 May 2014
Let's say that rho ranged from 0.7 to 7.5. So rhoMax-rhoMin = 7.5-.5 = 7. So you will have 7 color steps when hsv(7) returns. And that's what you have: 7 color steps. It makes those steps (i.e. the tick mark labels) go from rhoMax to rhoMax, which is the range in your image.. If your rho went from 1001 to 1009, you'd have 8 color steps (1009 - 1001( and the tick marks would go from 1001 to 1009 because that's what's in your image. Does that make sense?
  23 Comments
Haimon
Haimon on 3 Jun 2014
Edited: Haimon on 3 Jun 2014
The part of the code with imshow is this:
imshow(rho, []);
colormap(hsv(rhomax-rhomin));
cbh = colorbar('location', 'SouthOutside');
set(cbh, 'Units', 'normal', 'Xtick',0:0.5:10);
text(3.5, -1, 'Densidade (g/cm³)', 'Parent', cbh);
and the next line is this:
r = sprintf('rho%04d.tif',d);
imwrite(rho,hsv((ceil(rhomax-rhomin))),r,'tif')
They are one after the other so there isn't anything between those two parts, or variables, or code, that change the colormap. Also I got those two from the same original variable, in the same run, so I also did not change my initial variable.

Sign in to comment.

Categories

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!