Removal of haze using Python detailEnhanceFilter

background

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

Implementation

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()

Execution result

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/

Input image

input.jpg

Output image

result.jpg

Adobe's haze removal

ado.jpg

Impressions

~~ 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.

Library

version
Python 3.7.6
opencv-python 4.1.2.30
numpy 1.18.1
pillow 7.0.0

Recommended Posts

Removal of haze using Python detailEnhanceFilter
python: Basics of using scikit-learn ①
Implementation of desktop notifications using Python
Python: Basics of image recognition using CNN
[Python] Extension using inheritance of matplotlib (NavigationToolbar2TK)
Automatic collection of stock prices using python
About building GUI using TKinter of Python
(Bad) practice of using this in Python
Python: Application of image recognition using CNN
Study on Tokyo Rent Using Python (3-1 of 3)
Meaning of using DI framework in Python
Introduction of Python
Start using Python
Basics of Python ①
Basics of python ①
Copy of python
Scraping using Python
Introduction of Python
Time variation analysis of black holes using python
Introduction of Python Imaging Library (PIL) using HomeBrew
Character encoding when using csv module of python 2.7.3
Try using the collections module (ChainMap) of python3
Anonymous upload of images using Imgur API (using Python)
Find the geometric mean of n! Using Python
Python introductory study-output of sales data using tuples-
Summary of Excel operations using OpenPyXL in Python
[Python] Implementation of clustering using a mixed Gaussian model
[Python] Operation of enumerate
List of python modules
Operate Redmine using Python Redmine
Explanation of the concept of regression analysis using python Part 2
Basics of I / O screen using tkinter in python3
[Python] [Word] [python-docx] Simple analysis of diff data using python
Fibonacci sequence using Python
Copy of python preferences
Cut a part of the string using a Python slice
Data analysis using Python 0
Basics of Python scraping basics
[python] behavior of argmax
Try projective transformation of images using OpenCV with Python
Derivatives Learned Using Python-(1) Calculation of Forward Exchange Rate-
Usage of Python locals ()
the zen of Python
[Question] About API conversion of chat bot using Python
Data cleaning using Python
Installation of Python 3.3 rc1
The pain of gRPC using Python. November 2019. (Personal memo)
Using Python #external packages
[Python] Using Line API [1st Creation of Beauty Bot]
Explanation of the concept of regression analysis using Python Part 1
WiringPi-SPI communication using Python
[Python] Summary of table creation method using DataFrame (pandas)
Age calculation using python
# 4 [python] Basics of functions
Basic knowledge of Python
Search Twitter using Python
Sober trivia of python3
Summary of Python arguments
Explanation of the concept of regression analysis using Python Extra 1
Study from the beginning of Python Hour8: Using packages
Example of using lambda