0

io.imread fails to read grayscale jpg image file correctly. Produces an image of just gray noise.

Receive this error: "Low image data range; displaying image with stretched contrast."

I have a stack of 20 almost identical images with the same dimensions, 1024 x 1280. Some display normally, but some just as gray noise. I've tried several read plugins and get the same result.

image = io.imread('Image_00019.jpg')  
plt.imshow(image, cmap='gray')

Expected: image displayed normally.
Actual: image displayed is just gray noise.

Derviş Kayımbaşıoğlu
  • 28,492
  • 4
  • 50
  • 72
DataJo
  • 1
  • 1

1 Answers1

0

Looks like it has to do with the automatic scaling of the colormap. And apparently the solution involves setting the vmin and vmax parameters to the scale of the original image, rather than the scale of the array read in by imread used by default.

Kind of unfortunate that the imread function is not able to determine the true scale from the original image file, and pass that info along to imshow automatically. But I suppose that is kind of extraneous additional info since imread is just strictly capturing the pixel array. Wouldn't this be a common cause of distortion in image display?

If anyone has any additional comments feel free to add.

problems low contrast image(contrast stretching) in matplotlib

DataJo
  • 1
  • 1