How to create a gray scale image

30 Ansichten (letzte 30 Tage)
maria
maria am 29 Nov. 2013
Kommentiert: maria am 1 Dez. 2013
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?

Akzeptierte Antwort

Image Analyst
Image Analyst am 29 Nov. 2013
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 Kommentare
Image Analyst
Image Analyst am 1 Dez. 2013
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 am 1 Dez. 2013
oh ok, thank you so much for your help :)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by