How to create a gray scale image

42 ビュー (過去 30 日間)
maria
maria 2013 年 11 月 29 日
コメント済み: maria 2013 年 12 月 1 日
Hi, i want to create a gray scale image in matlab so I write a matrix 5x7 lets say A=[0 0 0 0 0 0 0; 80 80 80 80 80 80 80;200 200 200 200 200 200 200; 110 110 110 110 110 110 110; 160 160 160 160 160 160 160;255 255 255 255 255 255 255] . Then i use the imshow command and I expect an image where every row has a different intensity, the first black, the last white and the others with intermediate values. Instead of that i get a picture where only the first row is black and the rest of them are white. what am i doing wrong?

採用された回答

Image Analyst
Image Analyst 2013 年 11 月 29 日
A is a double. Cast it to uint8:
imshow(uint8(A));
or else use [] if you want to keep A as a double:
imshow(A, []);
  7 件のコメント
Image Analyst
Image Analyst 2013 年 12 月 1 日
It's fine if it's a double. You'll get more accuracy that way. You only need to convert it to an integer if you want to do certain things, like store it in a standard image format.
maria
maria 2013 年 12 月 1 日
oh ok, thank you so much for your help :)

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

その他の回答 (0 件)

カテゴリ

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!

Translated by