Why does my colour bar not go up to the maximum values in the matrix?
조회 수: 5 (최근 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?
댓글 수: 0
채택된 답변
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:"
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
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
%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?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!