sjtrny / dark-channel-haze-removal Goto Github PK
View Code? Open in Web Editor NEWMATLAB implementation of "Single Image Haze Removal Using Dark Channel Prior"
License: MIT License
MATLAB implementation of "Single Image Haze Removal Using Dark Channel Prior"
License: MIT License
Hello, I am honored to read your paper. I would like to ask if this code is the original code of He Keming?
Hi Stephen, very nice code. I am trying to reproduce this method in R. I have a small question I came across while porting: in get_atmosphere.m
n_search_pixels = floor(n_pixels * 0.01);
In the reference paper (http://research.microsoft.com/en-us/um/people/jiansun/papers/Dehaze_CVPR2009.pdf) it is stated
0.1% bright-est pixels in the dark channel. These pixels are most haze-opaque (bounded by yellow lines in Figure6(b)).
It doesn't make much difference (I would say) at the end since you take the average of the accumulated pixels, but I was wondering why you used 1% instead of 0.1%.
Many thanks in advance.
Hi @sjtrny
I was looking into get Laplacian and I was testing it with a very simple image (resize of the original forest image to 10% of the original size). I see that the win_inds
array becomes:
Empty matrix: 1-by-0
since n_min
becomes bigger than n_max
.
(When k
is around 8010 just to give you a reference.)
The emptiness of the matrix has problems that hit then num_neigh
that becomes 0 and win_var
becomes NaN
.
Is this behavior on purpose? I quite don't get it. Can you, please, give me some details on this? Since of course R, to which I am porting the code and idea, complains much more than matlab already when the indexes of the win_inds
don't match anymore the dimensions.
Many thanks in advance.
In your get_atmoshpere.m code, you first select top 1% percent brightest pixels in the dark channel. Then, the average intensity of these pixels in the original input hazy images is regarded as the atmospheric light. However, this does not match the original paper (Single Image Haze Removal Using Dark Channel Prior) that illustrates the atmospheric light is considered as the pixels with highest intensity (mean intensity of each channel) in the input hazy image I are selected the atmosphere light.
Therefore, I provide my revised code based on your given code.
function atmosphere = get_atmosphere(image, dark_channel)
[m, n, ~] = size(image);
n_pixels = m * n;
n_search_pixels = floor(n_pixels * 0.001);
dark_vec = reshape(dark_channel, n_pixels, 1);
image_vec = reshape(image, n_pixels, 3);
[~, indices] = sort(dark_vec, 'descend');
% accumulator = zeros(1, 3);
% for k = 1 : n_search_pixels
% accumulator = accumulator + image_vec(indices(k),:);
% end
%
% atmosphere = accumulator / n_search_pixels;
atmosphere_search_pixels = zeros(n_search_pixels,3);
for k=1 : n_search_pixels
atmosphere_search_pixels(k,:) = image_vec(indices(k),:);
end
[~, top_intensity_indices] = sort(mean(atmosphere_search_pixels,2), 'descend');
atmosphere = atmosphere_search_pixels(top_intensity_indices(1),:);
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.