Image display with uint8 and double

63 ビュー (過去 30 日間)
Mohsin Shah
Mohsin Shah 2018 年 3 月 20 日
コメント済み: Anindya Banerjee 2019 年 12 月 17 日
Can someone explain why the following image, 'yinyang.png', is displayed differently when I use uint8 and double in the imshow function?
I = imread('yinyang.png');
figure(1), imshow(I); title('image displayed with uint8')
figure(2), imshow(double(I)); title('image displayed with double')
The original image displayed in Windows Photo Viewer and the two figure(1) and figure(2) are attached.

採用された回答

Stephen23
Stephen23 2018 年 3 月 20 日
編集済み: Stephen23 2019 年 9 月 11 日
It seems that you have a "binary" image with values 0 and 1, which is stored as uint8.
  • Because floating-point images are assumed to contain values between 0 and 1 the double image displays those colors as black and white.
  • But for the uint8 image the values are assumed to be from 0 to 255, so those two colors are shown as black and very-dark-gray (indeed, the symbol is just visible in your screenshot).
You can probably use imshow's optional input argument to specify the (non-default) range:
imshow(double(I),[0,255])
imshow(I,[0,1])
See also:
Addendum: the PNG standard supports 1-bit (i.e. binary) images, which MATLAB imports as logical images. Logical images are displayed as black-and-white.
  4 件のコメント
Mohsin Shah
Mohsin Shah 2018 年 3 月 20 日
編集済み: Mohsin Shah 2018 年 3 月 20 日
Yes, I agree with you. I think Photo Viewer also do some sort of scaling for making the image appear more prominent and clear.
Anindya Banerjee
Anindya Banerjee 2019 年 12 月 17 日
@ Stephen Cobeldick but inthe case of double, why the image turns out to be inverse? i.e white part of the image becomes black and black part becomes white?

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by