PNG image created in Matlab shows up as all black in imshow

조회 수: 21 (최근 30일)
Megan
Megan 2013년 12월 9일
댓글: Oliver Woodford 2013년 12월 10일
Hello,
I wrote some Matlab code that deBayers an image and writes the new RGB image out as a 3 x 16-bit png file:
imwrite(deBayeredImage, outputFileName, 'png', 'Bitdepth', 16);
Although the values are encoded as 16-bit, the actual range of values is 12-bit (ie, 0-4095).
If I load the image using A = imread('image.png'), the values appear reasonable. However, if I try to display the file using imshow (imshow(A) or imshow('image.png'), the display is all black, even though clicking on pixels in the figure shows the RGB values.
I thought that maybe I needed to reset the scale, but imshow(A, [0 4095]) does not change the all-black display.
Any idea what is going on?

채택된 답변

Oliver Woodford
Oliver Woodford 2013년 12월 9일
If you read the imshow help text, you'll see that the range only applies to grayscale images. Try:
imshow(double(A)/4095);
or
imdisp(A, [0 4095]);
where imdisp can be found on the File Exchange.
  댓글 수: 2
Megan
Megan 2013년 12월 9일
I thought that Matlab could handle png images with integer values if they were 8 or 16 bit. Is that just for writing/reading?
Oliver Woodford
Oliver Woodford 2013년 12월 10일
Yes. Because a png is an image file. The image array is not a png.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by