0

how to get clear images without data or color loss. So far I have tried many approaches using clahe algorithm and this post (per-pixel gain using localmax i.e background and mask) but in every approach, either data get lost or color.

Example image:

example image

My final output with the best approach used at that post:

my final output with the best approach used at that post

Desired output:

desired output

Color of images inside the input image also gets lost or fade.

kkuilla
  • 2,226
  • 3
  • 34
  • 37

1 Answers1

1

You can do a dynamic range stretch using Python/OpenCV/Skimage as follows. Adjust the in_range values as desired. Increasing the first one will darken the dark areas and decreasing the second one will lighten the light areas.

Input:

enter image description here

import cv2
import skimage.exposure


# load image with alpha channel
img = cv2.imread('delaware.jpg')

out1 = skimage.exposure.rescale_intensity(img, in_range=(50,190), out_range=(0,255))
cv2.imwrite('delaware.jpg_stretch_50_190.png', out1)

cv2.imshow('Out1', out1)
cv2.waitKey(0)
cv2.destroyAllWindows()

enter image description here

fmw42
  • 46,825
  • 10
  • 62
  • 80