Effacer les filtres
Effacer les filtres

Problem with colorbar and values of scale

13 vues (au cours des 30 derniers jours)
Haimon
Haimon le 8 Mai 2014
Commenté : Image Analyst le 3 Juin 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);

Réponses (1)

Image Analyst
Image Analyst le 8 Mai 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 commentaires
Haimon
Haimon le 3 Juin 2014
Modifié(e) : Haimon le 3 Juin 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.
Image Analyst
Image Analyst le 3 Juin 2014
I give the same answer as in your duplicate question: http://www.mathworks.com/matlabcentral/answers/132156#comment_217525

Connectez-vous pour commenter.

Catégories

En savoir plus sur Colormaps dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by