The problem about the display of image(Matlab2014b)

1 回表示 (過去 30 日間)
Y
Y 2017 年 9 月 11 日
コメント済み: Image Analyst 2017 年 9 月 11 日
Hello, everyone, the first part is the demo from help.
I=fitsread('solarspectra.fts');
I=mat2gray(I);
imshow(I);
What troubles me a lot is that if I leave out the second sentence %I=mat2gray; the image will be blank.Could U tell me the reason for that? Maybe the format is .mat? I am not sure. Thanks in advance. Hang Yang
  4 件のコメント
Y
Y 2017 年 9 月 11 日
Thanks a lot. Maybe I understand what you said before. Take any matrix as an example.
if true
b=[1,2;3,4];
subplot(1,2,1);
imshow(b);
subplot(1,2,2);
c=mat2gray(b);
imshow(c);
end
I can see difference between two picture.
The first one is blank due to the fact that we could not see
metadata directly and we need to convert it.
Is it right.
Best regards.
Guillaume
Guillaume 2017 年 9 月 11 日
The issue, as explained by the two actual answers, has nothing to do with metadata (whatever is meant by that in this case) and only to do with the range of values in the matrix.

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

採用された回答

Image Analyst
Image Analyst 2017 年 9 月 11 日
If you have a floating point image with values below 0, they will show up as black.
If you have a floating point image with values above 1, they will show up as white.
To get around this use [] in imshow():
imshow(I, []);
  1 件のコメント
Y
Y 2017 年 9 月 11 日
Thanks all the same.

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

その他の回答 (1 件)

Guillaume
Guillaume 2017 年 9 月 11 日
The image is not blank. It is all white.
Matlab assumes that an image of type double is in the range [0-1]. 0 being black, 1 being white. Any value below 0 is considered to be 0 (black), any value above 1 is considered to be 1 (white). This is most likely the case with your matrix where most (all) values are > 1.
As per its documentation mat2gray rescale your matrix to the [0-1] range, so it conforms to the above.
If you don't want to use mat2gray another option is to tell matlab to use the full range of intensities in your matrix. As per the documentation of imshow:
imshow(I, []) %will use the full image range, whatever that is, instead of [0-1] for double
  2 件のコメント
Y
Y 2017 年 9 月 11 日
Hh,thanks a lot.I start to learn image processing with Matlab. You are kindness.
Image Analyst
Image Analyst 2017 年 9 月 11 日
If you're just starting, make sure you check out my tutorials, especially the Image Segmentation Tutorial http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862&sort=downloads_desc

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

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!