What indicate the values in colorbar?

7 ビュー (過去 30 日間)
Yama Abawi
Yama Abawi 2021 年 10 月 10 日
コメント済み: DGM 2021 年 10 月 20 日
Hello,
I would be very thankful, if someone could answer these two questions:
The image "RB.jpg" is read and shown via the following code:
A = imread('RB.jpg');
figure;
imshow(A);
1) What are the values (between 0 and 1) indicating, if the colorbar is, as shown, activated?
2) What is changed in the image "RB.jpg" with the following code, and what are the meaning of the values in the colorbar now?
A = imread('RB.jpg');
figure;
imshow(A);
AA=mean(A,3);
figure;
imagesc(AA);
Thanks in advance :-)
Yama

採用された回答

DGM
DGM 2021 年 10 月 10 日
編集済み: DGM 2021 年 10 月 10 日
In the first example, it doesn't mean anything. It's not referring to the image as displayed by imshow(), since imshow() is not using the relevant color map to display the image.
A = imread('peppers.png');
imshow(A)
colorbar
However, imagesc() renders the image using the current colormap, and so the colorbar shows the mean pixel value. As the image is uint8 class, it's understandable that the mean values are somewhere in the midst of [0 255]
clf % just for web view
imagesc(mean(A,3))
colorbar
This might get a bit confusing as the behavior varies between RGB and single-channel images. For example, if you repeat the first example with a grayscale version of the image, then the colorbar does refer to the image pixel values.
clf % for web view
imshow(rgb2gray(A))
colorbar
In this case, it adopts a grayscale colormap, but there's nothing stopping you from using another colormap.
clf
imshow(rgb2gray(A))
colorbar
colormap(parula)
  2 件のコメント
Yama Abawi
Yama Abawi 2021 年 10 月 20 日
Thanks for your answer :-) But to be honest, I am still a little confused. What is meant by "mean pixel value"? I thought the pixel color code is a vector of three values. so what does (for example) the value 250 in the color bar mean?
Regards
DGM
DGM 2021 年 10 月 20 日
"mean pixel value" was specifically what you were calculating and displaying.
A = uint8(permute([64 128 255],[1 3 2])) % a single color tuple
A = 1×1×3 uint8 array
A(:,:,1) = 64 A(:,:,2) = 128 A(:,:,3) = 255
B = mean(A,3) % dim3 average
B = 149
This takes the simple average of RGB components, converting the image to a monochrome image with only one channel. Similarly,
C = rgb2gray(A) % 0.299*R + 0.587*G + 0.114*B
C = uint8 123
converts the RGB image to Y (luma), which is just a weighted average. The result is again a single-channel monochrome image. The value of the monochrome image is what's represented in the plot, and the colorbar represents whatever the monochrome image represents (e.g. the mean or a weighted mean)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeRed についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by