Utkarsh-Deshmukh / Single-Image-Dehazing-Python

python implementation of the paper: "Efficient Image Dehazing with Boundary Constraint and Contextual Regularization"
BSD 2-Clause "Simplified" License
97 stars 25 forks source link

difference in calling dehazing using pip package #2

Closed bmabir17-asj closed 3 years ago

bmabir17-asj commented 3 years ago

In the readme it show the implementation of the dehazing as follows

$ import image_dehazer                                      # Load the library

$ HazeImg = cv2.imread('image_path', 0)                     # read input image
$ HazeCorrectedImg = image_dehazer.remove_haze(HazeImg) 

That means we are loading the image as grayscale and simply passing that image in remove_haze function.

But in example.py we are doing the following https://github.com/Utkarsh-Deshmukh/Single-Image-Dehazing-Python/blob/393a51439a56f90f78aba50d6ba5b8e7a9a184a6/src/example.py#L14-L40

That is we are using the color image and calculating Transmission Airlight and then passing those values to removeHaze(HazeImg, Transmission, A, 0.85)

Is the pip documentation wrong/outdated? or image_dehazer.remove_haze(HazeImg) function calculates them internally? If so why we are using grayscale image?

Utkarsh-Deshmukh commented 3 years ago

You are right. There is a mistake in the documentation. I have corrected the mistake. You should be using a color image, and not a grayscale image

bmabir17-asj commented 3 years ago

@Utkarsh-Deshmukh Okey, thanks. But what about this?

That is we are using the color image and calculating Transmission Airlight and then passing those values to removeHaze(HazeImg, Transmission, A, 0.85)

is this being calculated internally in pip package?

bmabir17-asj commented 3 years ago

On Further Inspection i found that it does calculate internally

def remove_haze(HazeImg, airlightEstimation_windowSze=15, boundaryConstraint_windowSze=3, C0=20, C1=300, regularize_lambda=0.1, sigma=0.5, delta=0.85):
    Dehazer = image_dehazer(airlightEstimation_windowSze=airlightEstimation_windowSze,
                            boundaryConstraint_windowSze=boundaryConstraint_windowSze, C0=C0, C1=C1,
                            regularize_lambda=regularize_lambda, sigma=sigma, delta=delta)
    HazeCorrectedImg = Dehazer.remove_haze(HazeImg)

Thanks for the awesome package :smile:

yx-chan131 commented 1 year ago

Hi, why must it take color image but not a single channel image as input? @Utkarsh-Deshmukh

Utkarsh-Deshmukh commented 1 year ago

because in order to compute the airlight(which is later used to compute the haze transmission), we compute the dynamic range of the pixel within all the color channels