The pixel values are not all 255 in 256*256 matrix.But I get a white image.How?

4 ビュー (過去 30 日間)
Veera Kalyani S
Veera Kalyani S 2017 年 1 月 9 日
編集済み: Guillaume 2017 年 1 月 9 日
A 256*256 matrix consists of pixel values that varies from 1 to 256 randomly.
But the image displayed for the corresponding matrix is a white colored image.
how?
  1 件のコメント
Von Duesenberg
Von Duesenberg 2017 年 1 月 9 日
Could you please post your code? It would be easier to help you.

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

回答 (1 件)

Guillaume
Guillaume 2017 年 1 月 9 日
編集済み: Guillaume 2017 年 1 月 9 日
My guess is that you're using
imshow(someimage);
and someimage is of class double. The class of the image matters for imshow. If it is of class double, imshow assumes the range is [0-1], not [0-255]. imshow assumes [0-255] if the image is of class uint8. So, there's two ways to fix this:
  • convert your image to uint8:
someimage = uint8(someimage);
imshow(someimage);
  • or override the default range of imshow:
imshow(someimage, [0 255]);

Community Treasure Hunt

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

Start Hunting!

Translated by