Why does MATLAB read a picture and add noise on it?

Hi,
I typed in matlab the following command:
x=imread('pic.gif')
imshow(x);
I would expect that the output image look exactly like the one MATLAB read. However, it didn't happen. MATLAB gave an output that looked like the original one, but with a lot of noise... My question is why don't I get exactly the same image?

댓글 수: 4

Adam
Adam 2015년 3월 25일
편집: Adam 2015년 3월 25일
I don't have 'pic.gif' so it's rather difficult to say without any information or screenshots of the original and the Matlab imshow version.
M B
M B 2015년 3월 26일
Hi Adam, The picture is attached.
M B, I can't see the attachment either ...
M B
M B 2015년 3월 26일
I attatched it now to the original message.

댓글을 달려면 로그인하십시오.

 채택된 답변

Titus Edelhofer
Titus Edelhofer 2015년 3월 26일
Hi,
your image is an indexed image, not RGB. Therefore you need to read the colormap as well:
[a,b] = imread('pic.gif');
imshow(a);
colormap(b);
Titus

추가 답변 (1개)

Jan
Jan 2015년 3월 26일
Or:
[c, map] = imread('pic.gif');
img = ind2rgb(c, map);
imshow(img)

댓글 수: 4

M B
M B 2015년 3월 26일
thanks a lot
M B
M B 2015년 3월 26일
I wish to ask how MATLAB decided how to present the picture.
MATLAB got only one arguement, a data matrix (of an indexed image), without a colormap. How did MATLAB present the picture? How did MATLAB know what color to place in each pixel.
If you didn't supply a color map, and the image was uint8, then it just chose the gray scale colormap. But since the pixel value is really a row number into a colormap instead of an intensity value, the image most likely looked like a bunch of black/white/gray garbage/noise.
It was not 100% noise, since the colormap of the image had some similarity to simple gray scale. That's why it did not look completely weird but just "with some noise".

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

질문:

M B
2015년 3월 25일

댓글:

2015년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by