Why does my colour bar not go up to the maximum values in the matrix?
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Goncalo Costa
le 17 Août 2023
Commenté : Dyuman Joshi
le 17 Août 2023
I am imaging a matrix A with the following code:
I = imgaussfilt(A,2);
I2 = imsharpen(I);
I3 = imresize(I2, 5);
figure(3), imagesc(I3)
axis equal tight xy
set(gca,'linewidth',1.0,'fontsize',20)
xlabel('X [mm]')
ylabel('Y [mm]')
c1=colorbar('LineWidth',1.0,'FontSize',20)
and I am checking what the maximum values in the matrix that I am plotting are:
max(max(A))
min(min(A))
In this case the maximum value is 2.7634 and the minimum is 0.9786, but the plot that I obtain is the following:
Based on the distance between 1.5 and 2 we can see that the maximum value is not presented in the colorbar and we can see that the minimum value is also not presented.
Is this because these must be isolated values and therefore negligible in the colour plot? Or is the code doing something weird?
0 commentaires
Réponse acceptée
Dyuman Joshi
le 17 Août 2023
Modifié(e) : Dyuman Joshi
le 17 Août 2023
"and I am checking what the maximum values in the matrix that I am plotting are:"
And as you can observe, values in I3 are not equal to values in A, as you have performed operations on A to obtain I3, which have changed the values accodring to the functions implemented.
2 commentaires
Dyuman Joshi
le 17 Août 2023
"I thought that the scaling meant that the highest value in the colour bar would be the maximum value of A..."
Not A, I3.
The input to imagesc() is I3, not A. And as you are plotting I3, you should check the values of I3.
load('A.mat')
I = imgaussfilt(A,2);
I2 = imsharpen(I);
I3 = imresize(I2, 5);
figure(3)
imagesc(I3)
axis equal tight xy
set(gca,'linewidth',1.0,'fontsize',20)
xlabel('X [mm]')
ylabel('Y [mm]')
c1=colorbar('LineWidth',1.0,'FontSize',20);
%Get the limits of the colorbar
clim
%Get the minimum and maximum values of I3
[min(I3,[],'all') max(I3,[],'all')]
As you can see, they are in fact, equal.
"If I have a bunch of images/matrices, how could I normalise the colour to the overall maximum and minimum of all images?"
Do you want to perform the same operations as mentioned above on the bunch of images/matrices, and show them in a tiled layout?
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Orange 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!