From c16ba61435b2dc94c9871cee77bd2291febbc7fe Mon Sep 17 00:00:00 2001 From: JinweiClarkChao Date: Tue, 25 Aug 2015 16:48:29 +0800 Subject: add refs in README --- DCP.sln | 6 ----- DCP/DCP.vcxproj | 69 ++--------------------------------------------------- DCP/darkchannel.cpp | 12 ++++------ DCP/dcp.cpp | 13 ++++++++++ DCP/dcp.h | 1 - DCP/dcp_core.h | 2 ++ DCP/test.cpp | 2 +- README.md | 11 +++++---- 8 files changed, 29 insertions(+), 87 deletions(-) diff --git a/DCP.sln b/DCP.sln index 1310c0d..e23dbd2 100644 --- a/DCP.sln +++ b/DCP.sln @@ -8,19 +8,13 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 - Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1543533F-481B-40EC-BEFC-90E46456A5F8}.Debug|Win32.ActiveCfg = Debug|Win32 {1543533F-481B-40EC-BEFC-90E46456A5F8}.Debug|Win32.Build.0 = Debug|Win32 - {1543533F-481B-40EC-BEFC-90E46456A5F8}.Debug|x64.ActiveCfg = Debug|x64 - {1543533F-481B-40EC-BEFC-90E46456A5F8}.Debug|x64.Build.0 = Debug|x64 {1543533F-481B-40EC-BEFC-90E46456A5F8}.Release|Win32.ActiveCfg = Release|Win32 {1543533F-481B-40EC-BEFC-90E46456A5F8}.Release|Win32.Build.0 = Release|Win32 - {1543533F-481B-40EC-BEFC-90E46456A5F8}.Release|x64.ActiveCfg = Release|x64 - {1543533F-481B-40EC-BEFC-90E46456A5F8}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/DCP/DCP.vcxproj b/DCP/DCP.vcxproj index b2ef313..68eeb69 100644 --- a/DCP/DCP.vcxproj +++ b/DCP/DCP.vcxproj @@ -5,18 +5,10 @@ Debug Win32 - - Debug - x64 - Release Win32 - - Release - x64 - {1543533F-481B-40EC-BEFC-90E46456A5F8} @@ -30,12 +22,6 @@ v120 Unicode - - Application - true - v120 - Unicode - Application false @@ -43,31 +29,16 @@ true Unicode - - Application - false - v120 - true - Unicode - - - - - - + - - - - - + ed7df352 @@ -75,15 +46,9 @@ true - - true - false - - false - @@ -97,19 +62,6 @@ true - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - - Level3 @@ -127,23 +79,6 @@ true - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - diff --git a/DCP/darkchannel.cpp b/DCP/darkchannel.cpp index ab5a365..64d9963 100644 --- a/DCP/darkchannel.cpp +++ b/DCP/darkchannel.cpp @@ -25,14 +25,10 @@ void CalcDarkChannel(IplImage *darkchannel, IplImage *input, int radius) st_row = i - radius, ed_row = i + radius; st_col = j - radius, ed_col = j + radius; - if (st_row < 0) - st_row = 0; - if (ed_row >= height) - ed_row = height - 1; - if (st_col < 0) - st_col = 0; - if (ed_col >= width) - ed_col = width - 1; + st_row = st_row < 0 ? 0 : st_row; + ed_row = ed_row >= height ? (height - 1) : ed_row; + st_col = st_col < 0 ? 0 : st_col; + ed_col = ed_col >= width ? (width - 1) : ed_col; int cur = 0; int min = 300; diff --git a/DCP/dcp.cpp b/DCP/dcp.cpp index 716759c..97a597f 100644 --- a/DCP/dcp.cpp +++ b/DCP/dcp.cpp @@ -1,5 +1,7 @@ #include "dcp_core.h" +using namespace cv::ximgproc; + void dehaze(IplImage *recover, IplImage *input) { int height = input->height; @@ -30,7 +32,18 @@ void dehaze(IplImage *recover, IplImage *input) t.tic(); printf("GuidedFilterColor..."); + // GuidedFilterColor() is my own implementation of guided filter + // guidedFilter() is the implementation included in OpenCV 3.0 + // The result is almost the same, however my implementation is much more slower + // because I haven't spend much time optimizing the code efficiency. + + // See http://research.microsoft.com/en-us/um/people/kahe/eccv10/ for more details + // ref: + // He, Kaiming, Jian Sun, and Xiaoou Tang. "Guided image filtering." + // Pattern Analysis and Machine Intelligence, IEEE Transactions on 35.6 (2013): 1397-1409. + GuidedFilterColor(refine_transmission, input, transmission, 1e-6, 60); + // guidedFilter(cv::cvarrToMat(input), cv::cvarrToMat(transmission), cv::cvarrToMat(refine_transmission), 60, 1e-6); t.toc(); t.tic(); diff --git a/DCP/dcp.h b/DCP/dcp.h index 00c7e53..eb64d63 100644 --- a/DCP/dcp.h +++ b/DCP/dcp.h @@ -2,7 +2,6 @@ #define DCP_H #include "dcp_core.h" - void dehaze(IplImage *recover, IplImage *input); #endif \ No newline at end of file diff --git a/DCP/dcp_core.h b/DCP/dcp_core.h index 658e461..98db7a4 100644 --- a/DCP/dcp_core.h +++ b/DCP/dcp_core.h @@ -3,6 +3,8 @@ #include #include +#include +#include #include diff --git a/DCP/test.cpp b/DCP/test.cpp index 2af8719..7587c35 100644 --- a/DCP/test.cpp +++ b/DCP/test.cpp @@ -2,7 +2,7 @@ int main() { - IplImage *input = cvLoadImage("house-input.bmp"); + IplImage *input = cvLoadImage("input.png"); IplImage *result = cvCreateImage(cvGetSize(input), IPL_DEPTH_8U, 3); dehaze(result, input); diff --git a/README.md b/README.md index 5f1946b..911dd97 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,9 @@ -Implementation of Dark Channel Prior +## Single Image Haze Removal Using Dark Channel Prior -This repo is still under development. +Implementation of Single Image Haze Removal Using Dark Channel Prior. -He K, Sun J, Tang X. Single image haze removal using dark channel prior[J]. Pattern Analysis and -Machine Intelligence, IEEE Transactions on, 2011, 33(12): 2341-2353. +Dependence: OpenCV 3.0 + +### Ref ++ He K, Sun J, Tang X. Single image haze removal using dark channel prior[J]. Pattern Analysis and Machine Intelligence, IEEE Transactions on, 2011, 33(12): 2341-2353. ++ He, Kaiming, Jian Sun, and Xiaoou Tang. "Guided image filtering." Pattern Analysis and Machine Intelligence, IEEE Transactions on 35.6 (2013): 1397-1409. \ No newline at end of file -- cgit v1.2.3