Why does my colour bar not go up to the maximum values in the matrix?

4 次查看(过去 30 天)
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?

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-8-17
编辑:Dyuman Joshi 2023-8-17
"and I am checking what the maximum values in the matrix that I am plotting are:"
No, you are checking the values of A, whereas you are plotting the values of I3 via imagesc.
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 个评论
Goncalo Costa
Goncalo Costa 2023-8-17
Oh .... but it still isn't quite clear to me how this scaling works? I thought that the scaling meant that the highest value in the colour bar would be the maximum value of A and so on for the minimum. If this is not the case, how can there be consistency between the values in A and the colours shown?
If I have a bunch of images/matrices, how could I normalise the colour to the overall maximum and minimum of all images?
Thanks for your help.
Dyuman Joshi
Dyuman Joshi 2023-8-17
"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
ans = 1×2
0.9933 2.2033
%Get the minimum and maximum values of I3
[min(I3,[],'all') max(I3,[],'all')]
ans = 1×2
0.9933 2.2033
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?

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Red 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by