The photos you take may be unintentionally hazy. Therefore, there is a need to remove haze by using image processing on haze images.
If you actually look at the following site, Adobe products also have a haze removal function. site: https://blogs.adobe.com/japan/cc-adobe-stock-contributor-j-curbon-lightroom-how-to-goto-2/
This time, I will introduce a simple haze removal method using Python and OpenCV.
detailEnhanceFilter
This time, we will use the detailEnhanceFilter implemented in Non-Photorealistic Rendering of OpenCV.
Please check the following site for the details of the library. https://docs.opencv.org/master/df/dac/group__photo__render.html
image_processing.py
from PIL import Image
import numpy as np
import cv2
def main():
img = np.array(Image.open('images/input.jpg'))
dst = cv2.detailEnhance(img, sigma_s=10, sigma_r=0.15)
Image.fromarray(dst).save('images/result.jpg')
if __name__ == '__main__':
main()
For the input, I borrowed the image of the site introduced earlier. site: https://blogs.adobe.com/japan/cc-adobe-stock-contributor-j-curbon-lightroom-how-to-goto-2/
~~ Isn't it suspicious ... ~~ You can see that the edges are enhanced as the name of the advanced enhancement filter! However, there is an impression that the pixels around the edges are white. This conversion ability with just one line of function! OpenCV is great. This time I wanted to try the effect of only the detailEnhance filter, so I did not preprocess it at all. The impression is that increasing the pretreatment will improve the situation. The parameters are also unadjusted. If you are interested, please try it. Finally, the version of the library is as follows.
version | |
---|---|
Python | 3.7.6 |
opencv-python | 4.1.2.30 |
numpy | 1.18.1 |
pillow | 7.0.0 |
Recommended Posts