Reputation: 21
I am trying to save image after calculating local entropy of the image. I tried with cv2.imwrite
but it saved black images. I tried with io.imsave
. It saved the image but with a lossy conversion due to float32
to uint8
conversion. How to save the images without any loss?
Upvotes: 1
Views: 890
Reputation: 207425
You have a couple of choices. Either save to a format that supports floating point values, such as:
Or, use cv2.normalize()
to normalize your data's range and type to:
uint8
and save as JPEG or PNG, oruint16
and save as PNG.In general, if an image looks black or nearly black, it is because the values are all low and the image has limited contrast. You can bump up the contrast very simply with ImageMagick in your Terminal with:
magick DARKIMAGE.png -auto-level OUTPUT.png
Upvotes: 1