This python script is based on the implementation concenpt of haze removal from Zhiming Tan Et al. Research Paper
The whole technique is based on three steps,
- Inverting the low light image
- Applying the Haze Removal technique on the inverted image
- Invert the enhanced image
The removal part comprises of three steps,
- Determine the intensity of atmospheric light. *
- Estimate transmission map.
- Clarify image.
- This in our case is constant which is 255, obtain from experimenting on multiple images. This will be updated so that it is calculated through a function. Si nce it was taking too long to compute this value it is better to find the average value of a batch.
Intensity of atmospheric light A
is estimated form hazed image I(x)
Transmission map t(x)
is estimated using A
and I(x)
Image is clarified with the image defogging model
Finding the top 0.1% brightest pixels in the dark channel then choose one with highest intensity as the representing of atmospheric light. This part is not needed in our case and thus ignored
Find a dark channel based on a local area(coarsemap)
Then, the transmission map t(x)
is thereby obtained:
t(x) = 1 – defoggingParam * darkPixelFromCoarseMap / AtmosphericLightIntensity
The defoggingParam
is a value between 0 to 1. The higher value the lesser amount of fog would be kept for the distant objects.
The image is clarified by: J(x)=(I(x)- A)/max(t(x), t0)+A
Where J(x)
is output, I(x)
is input, t(x)
is transmission map, A
is atmospheric light and t0
is set to a constant value to avoid dividing by zero.
Currently, the user has to specify the input image and output image path in a main() function. Next update will use console arguments to specify the image path. Feel free to add new things to the code and pull a merge request.
cv2 numpy