imshow doesn't display png image file

5 visualizaciones (últimos 30 días)
R
R el 1 de Dic. de 2020
Comentada: R el 1 de Dic. de 2020
Hi,
I'm trying to read and show the attached png file using imread and imshow fuctions, respectively. But the resulting image is only black. Any idea where I'm going wrong?
Thanks,
PS: The code I'm using is:
img = imread('scale2_int_1000ms_frm_1_0.png');
imshow(img)

Respuesta aceptada

Steve Eddins
Steve Eddins el 1 de Dic. de 2020
Your image is stored in the PNG file as unsigned 16-bit integers. When imshow displays a uint16 image, it uses the unsigned 16-bit range by default: 0 is black, and 65535 is white.
Your image has one pixel with the value 32666 near the upper right corner, and it appears that all the other pixel values are less than 3000. In fact, almost all of the pixels equal 2843. When viewed on a [0,65535] scale, these values are almost black. Try setting the display range explicitly when you call imshow:
imshow(img,[0 2843])
Here's what that looks like:
  1 comentario
R
R el 1 de Dic. de 2020
Thanks for the quick reply. This was very helpful. I have obviously made a mistake during image acquisition. Too long integration time, probably.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Image Processing Toolbox en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by