├── .gitignore ├── CMakeLists.txt ├── FastGuidedFilter ├── fastguidedfilter.cpp └── fastguidedfilter.h ├── README.md ├── imgs ├── I:color_result_s:1_r:2_eps:0.100000^2.png ├── I:color_result_s:1_r:2_eps:0.200000^2.png ├── I:color_result_s:1_r:2_eps:0.400000^2.png ├── I:color_result_s:1_r:4_eps:0.100000^2.png ├── I:color_result_s:1_r:4_eps:0.200000^2.png ├── I:color_result_s:1_r:4_eps:0.400000^2.png ├── I:color_result_s:1_r:8_eps:0.100000^2.png ├── I:color_result_s:1_r:8_eps:0.200000^2.png ├── I:color_result_s:1_r:8_eps:0.400000^2.png ├── I:color_result_s:2_r:2_eps:0.100000^2.png ├── I:color_result_s:2_r:2_eps:0.200000^2.png ├── I:color_result_s:2_r:2_eps:0.400000^2.png ├── I:color_result_s:2_r:4_eps:0.100000^2.png ├── I:color_result_s:2_r:4_eps:0.200000^2.png ├── I:color_result_s:2_r:4_eps:0.400000^2.png ├── I:color_result_s:2_r:8_eps:0.100000^2.png ├── I:color_result_s:2_r:8_eps:0.200000^2.png ├── I:color_result_s:2_r:8_eps:0.400000^2.png ├── I:gray_result_s:1_r:2_eps:0.100000^2.png ├── I:gray_result_s:1_r:2_eps:0.200000^2.png ├── I:gray_result_s:1_r:2_eps:0.400000^2.png ├── I:gray_result_s:1_r:4_eps:0.100000^2.png ├── I:gray_result_s:1_r:4_eps:0.200000^2.png ├── I:gray_result_s:1_r:4_eps:0.400000^2.png ├── I:gray_result_s:1_r:8_eps:0.100000^2.png ├── I:gray_result_s:1_r:8_eps:0.200000^2.png ├── I:gray_result_s:1_r:8_eps:0.400000^2.png ├── I:gray_result_s:2_r:2_eps:0.100000^2.png ├── I:gray_result_s:2_r:2_eps:0.200000^2.png ├── I:gray_result_s:2_r:2_eps:0.400000^2.png ├── I:gray_result_s:2_r:4_eps:0.100000^2.png ├── I:gray_result_s:2_r:4_eps:0.200000^2.png ├── I:gray_result_s:2_r:4_eps:0.400000^2.png ├── I:gray_result_s:2_r:8_eps:0.100000^2.png ├── I:gray_result_s:2_r:8_eps:0.200000^2.png ├── I:gray_result_s:2_r:8_eps:0.400000^2.png ├── cat.png ├── chian_2.png ├── china_1.png ├── people.png ├── result_s:1_r:2_eps:0.100000^2.png ├── result_s:1_r:2_eps:0.200000^2.png ├── result_s:1_r:2_eps:0.400000^2.png ├── result_s:1_r:4_eps:0.100000^2.png ├── result_s:1_r:4_eps:0.200000^2.png ├── result_s:1_r:4_eps:0.400000^2.png ├── result_s:1_r:8_eps:0.100000^2.png ├── result_s:1_r:8_eps:0.200000^2.png ├── result_s:1_r:8_eps:0.400000^2.png ├── result_s:2_r:2_eps:0.100000^2.png ├── result_s:2_r:2_eps:0.200000^2.png ├── result_s:2_r:2_eps:0.400000^2.png ├── result_s:2_r:4_eps:0.100000^2.png ├── result_s:2_r:4_eps:0.200000^2.png ├── result_s:2_r:4_eps:0.400000^2.png ├── result_s:2_r:8_eps:0.100000^2.png ├── result_s:2_r:8_eps:0.200000^2.png └── result_s:2_r:8_eps:0.400000^2.png ├── main.cpp └── paper ├── Fast Guided Filter.pdf └── pami12guidedfilter.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | # build dir 2 | cmake-build-debug/ 3 | # Compiled Object files 4 | *.slo 5 | *.lo 6 | *.o 7 | *.obj 8 | 9 | # Precompiled Headers 10 | *.gch 11 | *.pch 12 | 13 | # Compiled Dynamic libraries 14 | *.so 15 | *.dylib 16 | *.dll 17 | 18 | # Fortran module files 19 | *.mod 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | .idea/ 32 | .git 33 | .git-credentials 34 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5) 2 | set(PROJECT_NAME fast-guided-filter) 3 | project(${PROJECT_NAME}) 4 | set(CMAKE_CXX_STANDARD 11) 5 | FIND_PACKAGE(OpenCV REQUIRED) 6 | INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS}) 7 | 8 | file(GLOB SOURCE_FILES ./*.cpp ./FastGuidedFilter/*.cpp) 9 | include_directories (./ /usr/local/include /usr/local/include/opencv /usr/local/include/opencv2) 10 | add_executable(${PROJECT_NAME} ${SOURCE_FILES}) 11 | target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBS}) -------------------------------------------------------------------------------- /FastGuidedFilter/fastguidedfilter.cpp: -------------------------------------------------------------------------------- 1 | #include "fastguidedfilter.h" 2 | static cv::Mat boxfilter(const cv::Mat &I, int r) 3 | { 4 | cv::Mat result; 5 | cv::blur(I, result, cv::Size(r, r)); 6 | return result; 7 | } 8 | 9 | static cv::Mat convertTo(const cv::Mat &mat, int depth) 10 | { 11 | if (mat.depth() == depth) 12 | return mat; 13 | 14 | cv::Mat result; 15 | mat.convertTo(result, depth); 16 | return result; 17 | } 18 | 19 | class FastGuidedFilterImpl 20 | { 21 | public: 22 | FastGuidedFilterImpl(int r, double eps,int s):r(r),eps(eps),s(s){} 23 | virtual ~FastGuidedFilterImpl() {} 24 | 25 | cv::Mat filter(const cv::Mat &p, int depth); 26 | 27 | protected: 28 | int Idepth,r,s; 29 | double eps; 30 | 31 | private: 32 | virtual cv::Mat filterSingleChannel(const cv::Mat &p) const = 0; 33 | }; 34 | 35 | class FastGuidedFilterMono : public FastGuidedFilterImpl 36 | { 37 | public: 38 | FastGuidedFilterMono(const cv::Mat &I, int r, double eps,int s); 39 | 40 | private: 41 | virtual cv::Mat filterSingleChannel(const cv::Mat &p) const; 42 | 43 | private: 44 | 45 | cv::Mat I,origI, mean_I, var_I; 46 | }; 47 | 48 | class FastGuidedFilterColor : public FastGuidedFilterImpl 49 | { 50 | public: 51 | FastGuidedFilterColor(const cv::Mat &I, int r, double eps,int s); 52 | 53 | private: 54 | virtual cv::Mat filterSingleChannel(const cv::Mat &p) const; 55 | 56 | private: 57 | std::vector origIchannels,Ichannels; 58 | cv::Mat mean_I_r, mean_I_g, mean_I_b; 59 | cv::Mat invrr, invrg, invrb, invgg, invgb, invbb; 60 | }; 61 | 62 | 63 | cv::Mat FastGuidedFilterImpl::filter(const cv::Mat &p, int depth) 64 | { 65 | cv::Mat p2 = convertTo(p, Idepth); 66 | cv::resize(p2 ,p2,cv::Size(p2.cols/s,p2.rows/s),0,0,CV_INTER_NN); 67 | cv::Mat result; 68 | if (p.channels() == 1) 69 | { 70 | result = filterSingleChannel(p2); 71 | } 72 | else 73 | { 74 | std::vector pc; 75 | cv::split(p2, pc); 76 | 77 | for (std::size_t i = 0; i < pc.size(); ++i) 78 | pc[i] = filterSingleChannel(pc[i]); 79 | 80 | cv::merge(pc, result); 81 | } 82 | 83 | return convertTo(result, depth == -1 ? p.depth() : depth); 84 | } 85 | 86 | FastGuidedFilterMono::FastGuidedFilterMono(const cv::Mat &origI, int r, double eps,int s):FastGuidedFilterImpl(r,eps,s) 87 | { 88 | 89 | if (origI.depth() == CV_32F || origI.depth() == CV_64F) 90 | this->origI = origI.clone(); 91 | else 92 | this->origI = convertTo(origI, CV_32F); 93 | cv::resize(this->origI ,I,cv::Size(this->origI.cols/s,this->origI.rows/s),0,0,CV_INTER_NN); 94 | Idepth = I.depth(); 95 | 96 | mean_I = boxfilter(I, r); 97 | cv::Mat mean_II = boxfilter(I.mul(I), r); 98 | var_I = mean_II - mean_I.mul(mean_I); 99 | } 100 | 101 | cv::Mat FastGuidedFilterMono::filterSingleChannel(const cv::Mat &p) const 102 | { 103 | 104 | cv::Mat mean_p = boxfilter(p, r); 105 | cv::Mat mean_Ip = boxfilter(I.mul(p), r); 106 | cv::Mat cov_Ip = mean_Ip - mean_I.mul(mean_p); // this is the covariance of (I, p) in each local patch. 107 | 108 | cv::Mat a = cov_Ip / (var_I + eps); 109 | cv::Mat b = mean_p - a.mul(mean_I); 110 | 111 | cv::Mat mean_a = boxfilter(a, r); 112 | cv::Mat mean_b = boxfilter(b, r); 113 | cv::resize(mean_a ,mean_a,cv::Size(origI.cols,origI.rows),0,0,CV_INTER_LINEAR); 114 | cv::resize(mean_b ,mean_b,cv::Size(origI.cols,origI.rows),0,0,CV_INTER_LINEAR); 115 | return mean_a.mul(origI) + mean_b; 116 | } 117 | 118 | FastGuidedFilterColor::FastGuidedFilterColor(const cv::Mat &origI, int r, double eps, int s):FastGuidedFilterImpl(r,eps,s)// : r(r), eps(eps) 119 | { 120 | 121 | cv::Mat I; 122 | if (origI.depth() == CV_32F || origI.depth() == CV_64F) 123 | I = origI.clone(); 124 | else 125 | I = convertTo(origI, CV_32F); 126 | Idepth = I.depth(); 127 | 128 | cv::split(I, origIchannels); 129 | cv::resize(I,I,cv::Size(I.cols/s,I.rows/s),0,0,CV_INTER_NN); 130 | cv::split(I, Ichannels); 131 | 132 | mean_I_r = boxfilter(Ichannels[0], r); 133 | mean_I_g = boxfilter(Ichannels[1], r); 134 | mean_I_b = boxfilter(Ichannels[2], r); 135 | 136 | // variance of I in each local patch: the matrix Sigma. 137 | // Note the variance in each local patch is a 3x3 symmetric matrix: 138 | // rr, rg, rb 139 | // Sigma = rg, gg, gb 140 | // rb, gb, bb 141 | cv::Mat var_I_rr = boxfilter(Ichannels[0].mul(Ichannels[0]), r) - mean_I_r.mul(mean_I_r) + eps; 142 | cv::Mat var_I_rg = boxfilter(Ichannels[0].mul(Ichannels[1]), r) - mean_I_r.mul(mean_I_g); 143 | cv::Mat var_I_rb = boxfilter(Ichannels[0].mul(Ichannels[2]), r) - mean_I_r.mul(mean_I_b); 144 | cv::Mat var_I_gg = boxfilter(Ichannels[1].mul(Ichannels[1]), r) - mean_I_g.mul(mean_I_g) + eps; 145 | cv::Mat var_I_gb = boxfilter(Ichannels[1].mul(Ichannels[2]), r) - mean_I_g.mul(mean_I_b); 146 | cv::Mat var_I_bb = boxfilter(Ichannels[2].mul(Ichannels[2]), r) - mean_I_b.mul(mean_I_b) + eps; 147 | 148 | // Inverse of Sigma + eps * I 149 | invrr = var_I_gg.mul(var_I_bb) - var_I_gb.mul(var_I_gb); 150 | invrg = var_I_gb.mul(var_I_rb) - var_I_rg.mul(var_I_bb); 151 | invrb = var_I_rg.mul(var_I_gb) - var_I_gg.mul(var_I_rb); 152 | invgg = var_I_rr.mul(var_I_bb) - var_I_rb.mul(var_I_rb); 153 | invgb = var_I_rb.mul(var_I_rg) - var_I_rr.mul(var_I_gb); 154 | invbb = var_I_rr.mul(var_I_gg) - var_I_rg.mul(var_I_rg); 155 | 156 | cv::Mat covDet = invrr.mul(var_I_rr) + invrg.mul(var_I_rg) + invrb.mul(var_I_rb); 157 | 158 | invrr /= covDet; 159 | invrg /= covDet; 160 | invrb /= covDet; 161 | invgg /= covDet; 162 | invgb /= covDet; 163 | invbb /= covDet; 164 | } 165 | 166 | cv::Mat FastGuidedFilterColor::filterSingleChannel(const cv::Mat &p) const 167 | { 168 | cv::Mat mean_p = boxfilter(p, r); 169 | 170 | cv::Mat mean_Ip_r = boxfilter(Ichannels[0].mul(p), r); 171 | cv::Mat mean_Ip_g = boxfilter(Ichannels[1].mul(p), r); 172 | cv::Mat mean_Ip_b = boxfilter(Ichannels[2].mul(p), r); 173 | 174 | // covariance of (I, p) in each local patch. 175 | cv::Mat cov_Ip_r = mean_Ip_r - mean_I_r.mul(mean_p); 176 | cv::Mat cov_Ip_g = mean_Ip_g - mean_I_g.mul(mean_p); 177 | cv::Mat cov_Ip_b = mean_Ip_b - mean_I_b.mul(mean_p); 178 | 179 | cv::Mat a_r = invrr.mul(cov_Ip_r) + invrg.mul(cov_Ip_g) + invrb.mul(cov_Ip_b); 180 | cv::Mat a_g = invrg.mul(cov_Ip_r) + invgg.mul(cov_Ip_g) + invgb.mul(cov_Ip_b); 181 | cv::Mat a_b = invrb.mul(cov_Ip_r) + invgb.mul(cov_Ip_g) + invbb.mul(cov_Ip_b); 182 | 183 | cv::Mat b = mean_p - a_r.mul(mean_I_r) - a_g.mul(mean_I_g) - a_b.mul(mean_I_b); 184 | 185 | cv::Mat mean_a_r = boxfilter(a_r, r); 186 | cv::Mat mean_a_g = boxfilter(a_g, r); 187 | cv::Mat mean_a_b = boxfilter(a_b, r); 188 | cv::Mat mean_b = boxfilter(b, r); 189 | cv::resize(mean_a_r ,mean_a_r,cv::Size(origIchannels[0].cols,origIchannels[0].rows),0,0,CV_INTER_LINEAR); 190 | cv::resize(mean_a_g ,mean_a_g,cv::Size(origIchannels[1].cols,origIchannels[1].rows),0,0,CV_INTER_LINEAR); 191 | cv::resize(mean_a_b ,mean_a_b,cv::Size(origIchannels[2].cols,origIchannels[2].rows),0,0,CV_INTER_LINEAR); 192 | cv::resize(mean_b,mean_b,cv::Size(origIchannels[2].cols,origIchannels[2].rows),0,0,CV_INTER_LINEAR); 193 | return (mean_a_r.mul(origIchannels[0]) +mean_a_g.mul(origIchannels[1]) +mean_a_b.mul(origIchannels[2]) + mean_b); 194 | 195 | } 196 | 197 | 198 | FastGuidedFilter::FastGuidedFilter(const cv::Mat &I, int r, double eps,int s) 199 | { 200 | CV_Assert(I.channels() == 1 || I.channels() == 3); 201 | 202 | if (I.channels() == 1) 203 | impl_ = new FastGuidedFilterMono(I, 2 * (r/s) + 1, eps,s); 204 | else 205 | impl_ = new FastGuidedFilterColor(I, 2 * (r/s) + 1, eps,s); 206 | } 207 | 208 | FastGuidedFilter::~FastGuidedFilter() 209 | { 210 | delete impl_; 211 | } 212 | 213 | cv::Mat FastGuidedFilter::filter(const cv::Mat &p, int depth) const 214 | { 215 | return impl_->filter(p, depth); 216 | } 217 | 218 | cv::Mat fastGuidedFilter(const cv::Mat &I, const cv::Mat &p, int r, double eps, int s,int depth) 219 | { 220 | return FastGuidedFilter(I, r, eps,s).filter(p, depth); 221 | } 222 | -------------------------------------------------------------------------------- /FastGuidedFilter/fastguidedfilter.h: -------------------------------------------------------------------------------- 1 | #ifndef GUIDED_FILTER_H 2 | #define GUIDED_FILTER_H 3 | 4 | #include 5 | 6 | class FastGuidedFilterImpl; 7 | 8 | class FastGuidedFilter 9 | { 10 | public: 11 | FastGuidedFilter(const cv::Mat &I, int r, double eps,int s); 12 | ~FastGuidedFilter(); 13 | 14 | cv::Mat filter(const cv::Mat &p, int depth = -1) const; 15 | 16 | private: 17 | FastGuidedFilterImpl *impl_; 18 | }; 19 | 20 | cv::Mat fastGuidedFilter(const cv::Mat &I, const cv::Mat &p, int r, double eps, int s = 1,int depth = -1); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fast Guided filter for OpenCV 2 | 3 | Fast Guided filter is an edge-preserving smoothing filter like the bilateral filter. It is straightforward to implement and has linear complexity independent of the kernel size. For more details about this filter see[[Guided filte]](http://kaiminghe.com/publications/pami12guidedfilter.pdf) [[Fast Guided filte]](https://arxiv.org/pdf/1505.00996.pdf). 4 | 5 | 6 | ## Usage 7 | 8 | The interface consists of one simple function `fastGuidedFilter` and a class `FastGuidedFilter`. If you have multiple images to filter with the same guidance image then use `FastGuidedFilter` class to avoid extra computations on initialization stage. The code supports single-channel and 3-channel (color) guidance images and `CV_8U`, `CV_8S`, `CV_16U`, `CV_16S`, `CV_32S`, `CV_32F` and `CV_64F` data types. 9 | ``` 10 | $ mkdir build && cd build 11 | $ cmake .. 12 | $ make 13 | $ ./fast-guided-filter 14 | ``` 15 | 16 | ## Examples 17 | 18 | These examples are adapted from the [original MATLAB implementation](http://kaiminghe.com/eccv10/fast-guided-filter-code-v1.rar). 19 | 20 | ### Smoothing 21 | #### P: GrayScale I: GrayScale 22 | 23 | ```c++ 24 | int R[]={2,4,8}; 25 | double EPS[]={0.1,0.2,0.4}; 26 | Mat result; 27 | for(int s=1;s<=2;++s) { 28 | for (int i = 0; i < 3; ++i) { 29 | for (int j = 0; j < 3; ++j) { 30 | Mat P = cv::imread("./imgs/cat.png", CV_LOAD_IMAGE_GRAYSCALE); 31 | Mat I; 32 | I = P; 33 | int r = R[i]; 34 | float eps = EPS[j]*EPS[j]; 35 | eps *= 255 * 255; 36 | clock_t start_time1 = clock(); 37 | result = fastGuidedFilter(I, P, r, eps, s); 38 | clock_t end_time1 = clock(); 39 | cout << "fastguidedfilter Running time is: " 40 | << static_cast(end_time1 - start_time1) / CLOCKS_PER_SEC * 1000 << "ms" << endl; 41 | string name = "result_s:" + to_string(s) + "_r:" + to_string(r) + "_eps:" + to_string(EPS[j]) + "^2.png"; 42 | imwrite(name, result); 43 | } 44 | } 45 | } 46 | 47 | 48 | ``` 49 | 50 | ![Cat](./imgs/cat.png) 51 | 52 | - r=2,eps=0.1^2 -0.4^2,s=1 time: 1.7ms 53 | 54 | ![r=2, eps=0.1^2](./imgs/result_s:1_r:2_eps:0.100000^2.png) 55 | ![r=2, eps=0.2^2](./imgs/result_s:1_r:2_eps:0.200000^2.png) 56 | ![r=2, eps=0.4^2](./imgs/result_s:1_r:2_eps:0.400000^2.png) 57 | 58 | - r=2,eps=0.1^2 -0.4^2,s=2 time: 0.6ms 59 | 60 | ![r=2, eps=0.1^2](./imgs/result_s:2_r:2_eps:0.100000^2.png) 61 | ![r=2, eps=0.2^2](./imgs/result_s:2_r:2_eps:0.200000^2.png) 62 | ![r=2, eps=0.4^2](./imgs/result_s:2_r:2_eps:0.400000^2.png) 63 | 64 | - r=4,eps=0.1^2 -0.4^2,s=1 time: 1.7ms 65 | 66 | ![r=4, eps=0.1^2](./imgs/result_s:1_r:4_eps:0.100000^2.png) 67 | ![r=4, eps=0.2^2](./imgs/result_s:1_r:4_eps:0.200000^2.png) 68 | ![r=4, eps=0.4^2](./imgs/result_s:1_r:4_eps:0.400000^2.png) 69 | 70 | - r=4,eps=0.1^2 -0.4^2,s=2 time: 0.6ms 71 | 72 | ![r=4, eps=0.1^2](./imgs/result_s:2_r:4_eps:0.100000^2.png) 73 | ![r=4, eps=0.2^2](./imgs/result_s:2_r:4_eps:0.200000^2.png) 74 | ![r=4, eps=0.4^2](./imgs/result_s:2_r:4_eps:0.400000^2.png) 75 | 76 | - r=8,eps=0.1^2 -0.4^2,s=1 time: 1.7ms 77 | 78 | ![r=8, eps=0.1^2](./imgs/result_s:1_r:8_eps:0.100000^2.png) 79 | ![r=8, eps=0.2^2](./imgs/result_s:1_r:8_eps:0.200000^2.png) 80 | ![r=8, eps=0.4^2](./imgs/result_s:1_r:8_eps:0.400000^2.png) 81 | 82 | - r=8,eps=0.1^2 -0.4^2,s=2 time: 0.6ms 83 | 84 | ![r=8, eps=0.1^2](./imgs/result_s:2_r:8_eps:0.100000^2.png) 85 | ![r=8, eps=0.2^2](./imgs/result_s:2_r:8_eps:0.200000^2.png) 86 | ![r=8, eps=0.4^2](./imgs/result_s:2_r:8_eps:0.400000^2.png) 87 | 88 | #### P: RGB(3 channels) I: GrayScale or RGB 89 | ```c++ 90 | int R[]={2,4,8}; 91 | double EPS[]={0.1,0.2,0.4}; 92 | Mat result; 93 | for(int s=1;s<=2;++s) { 94 | for (int i = 0; i < 3; ++i) { 95 | for (int j = 0; j < 3; ++j) { 96 | Mat P = imread("../imgs/people.png", CV_LOAD_IMAGE_ANYCOLOR); 97 | Mat I; 98 | //cvtColor(P,I,CV_BGR2GRAY); 99 | I = P; 100 | int r = R[i]; 101 | float eps = EPS[j]*EPS[j]; 102 | eps *= 255 * 255; 103 | clock_t start_time1 = clock(); 104 | result = fastGuidedFilter(I, P, r, eps, s); 105 | clock_t end_time1 = clock(); 106 | cout << "fastguidedfilter Running time is: " 107 | << static_cast(end_time1 - start_time1) / CLOCKS_PER_SEC * 1000 << "ms" << endl; 108 | string name = "I:color_result_s:" + to_string(s) + "_r:" + to_string(r) + "_eps:" + to_string(EPS[j]) + "^2.png"; 109 | imwrite(name, result); 110 | } 111 | } 112 | } 113 | ``` 114 | ![People](./imgs/people.png) 115 | - I=grayscale r=2,eps=0.1^2 -0.4^2,s=1 time: 6ms 116 | 117 | ![I=grayscale r=2, eps=0.1^2](./imgs/I:gray_result_s:1_r:2_eps:0.100000^2.png) 118 | ![I=grayscaler=2, eps=0.2^2](./imgs/I:gray_result_s:1_r:2_eps:0.200000^2.png) 119 | ![I=grayscaler=2, eps=0.4^2](./imgs/I:gray_result_s:1_r:2_eps:0.400000^2.png) 120 | 121 | - I=RGB r=2,eps=0.1^2 -0.4^2,s=1 time: 16ms 122 | 123 | ![I=RGB r=2, eps=0.1^2](./imgs/I:color_result_s:1_r:2_eps:0.100000^2.png) 124 | ![I=RGB r=2, eps=0.2^2](./imgs/I:color_result_s:1_r:2_eps:0.200000^2.png) 125 | ![I=RGB r=2, eps=0.4^2](./imgs/I:color_result_s:1_r:2_eps:0.400000^2.png) 126 | 127 | - I=RGB r=2,eps=0.1^2 -0.4^2,s=2 time: 6ms 128 | 129 | ![I=RGB r=2, eps=0.1^2](./imgs/I:color_result_s:2_r:2_eps:0.100000^2.png) 130 | ![I=RGB r=2, eps=0.2^2](./imgs/I:color_result_s:2_r:2_eps:0.200000^2.png) 131 | ![I=RGB r=2, eps=0.4^2](./imgs/I:color_result_s:2_r:2_eps:0.400000^2.png) 132 | 133 | - I=grayscale r=4,eps=0.1^2 -0.4^2,s=1 time: 6ms 134 | 135 | ![I=grayscale r=4, eps=0.1^2](./imgs/I:gray_result_s:1_r:4_eps:0.100000^2.png) 136 | ![I=grayscaler=4, eps=0.2^2](./imgs/I:gray_result_s:1_r:4_eps:0.200000^2.png) 137 | ![I=grayscaler=4, eps=0.4^2](./imgs/I:gray_result_s:1_r:4_eps:0.400000^2.png) 138 | 139 | - I=RGB r=4,eps=0.1^2 -0.4^2,s=1 time: 16ms 140 | 141 | ![I=RGB r=4, eps=0.1^2](./imgs/I:color_result_s:1_r:4_eps:0.100000^2.png) 142 | ![I=RGB r=4, eps=0.2^2](./imgs/I:color_result_s:1_r:4_eps:0.200000^2.png) 143 | ![I=RGB r=4, eps=0.4^2](./imgs/I:color_result_s:1_r:4_eps:0.400000^2.png) 144 | 145 | - I=RGB r=4,eps=0.1^2 -0.4^2,s=2 time: 6ms 146 | 147 | ![I=RGB r=4, eps=0.1^2](./imgs/I:color_result_s:2_r:4_eps:0.100000^2.png) 148 | ![I=RGB r=4, eps=0.2^2](./imgs/I:color_result_s:2_r:4_eps:0.200000^2.png) 149 | ![I=RGB r=4, eps=0.4^2](./imgs/I:color_result_s:2_r:4_eps:0.400000^2.png) 150 | 151 | I=grayscale r=8,eps=0.1^2 -0.4^2,s=1 time: 6ms 152 | 153 | ![I=grayscale r=8, eps=0.1^2](./imgs/I:gray_result_s:1_r:8_eps:0.100000^2.png) 154 | ![I=grayscaler=8, eps=0.2^2](./imgs/I:gray_result_s:1_r:8_eps:0.200000^2.png) 155 | ![I=grayscaler=8, eps=0.4^2](./imgs/I:gray_result_s:1_r:8_eps:0.400000^2.png) 156 | 157 | - I=RGB r=8,eps=0.1^2 -0.4^2,s=1 time: 16ms 158 | 159 | ![I=RGB r=8, eps=0.1^2](./imgs/I:color_result_s:1_r:8_eps:0.100000^2.png) 160 | ![I=RGB r=8, eps=0.2^2](./imgs/I:color_result_s:1_r:8_eps:0.200000^2.png) 161 | ![I=RGB r=8, eps=0.4^2](./imgs/I:color_result_s:1_r:8_eps:0.400000^2.png) 162 | 163 | - I=RGB r=8,eps=0.1^2 -0.4^2,s=2 time: 6ms 164 | 165 | ![I=RGB r=8, eps=0.1^2](./imgs/I:color_result_s:2_r:8_eps:0.100000^2.png) 166 | ![I=RGB r=8, eps=0.2^2](./imgs/I:color_result_s:2_r:8_eps:0.200000^2.png) 167 | ![I=RGB r=8, eps=0.4^2](./imgs/I:color_result_s:2_r:8_eps:0.400000^2.png) 168 | ### Flash/no-flash denoising 169 | 170 | ```c++ 171 | cv::Mat I = cv::imread("./img_flash/cave-flash.bmp", CV_LOAD_IMAGE_COLOR); 172 | cv::Mat p = cv::imread("./img_flash/cave-noflash.bmp", CV_LOAD_IMAGE_COLOR); 173 | 174 | int r = 8; 175 | double eps = 0.02 * 0.02; 176 | 177 | eps *= 255 * 255; // Because the intensity range of our images is [0, 255] 178 | 179 | cv::Mat q = guidedFilter(I, p, r, eps); 180 | ``` 181 | 182 | [![Cave Flash](http://atilimcetin.com/guided-filter/img_flash/cave-flash-small.png)](http://atilimcetin.com/guided-filter/img_flash/cave-flash.png) 183 | [![Cave No Flash](http://atilimcetin.com/guided-filter/img_flash/cave-noflash-small.png)](http://atilimcetin.com/guided-filter/img_flash/cave-noflash.png) 184 | [![Cave Denoised](http://atilimcetin.com/guided-filter/img_flash/cave-denoised-small.png)](http://atilimcetin.com/guided-filter/img_flash/cave-denoised.png) 185 | 186 | 187 | ### Feathering 188 | 189 | ```c++ 190 | cv::Mat I = cv::imread("./img_feathering/toy.bmp", CV_LOAD_IMAGE_COLOR); 191 | cv::Mat p = cv::imread("./img_feathering/toy-mask.bmp", CV_LOAD_IMAGE_GRAYSCALE); 192 | 193 | int r = 60; 194 | double eps = 1e-6; 195 | 196 | eps *= 255 * 255; // Because the intensity range of our images is [0, 255] 197 | 198 | cv::Mat q = guidedFilter(I, p, r, eps); 199 | ``` 200 | 201 | [![Mask](http://atilimcetin.com/guided-filter/img_feathering/toy-mask-small.png)](http://atilimcetin.com/guided-filter/img_feathering/toy-mask.png) 202 | [![Guidance](http://atilimcetin.com/guided-filter/img_feathering/toy-small.png)](http://atilimcetin.com/guided-filter/img_feathering/toy.png) 203 | [![Feathering](http://atilimcetin.com/guided-filter/img_feathering/toy-feather-small.png)](http://atilimcetin.com/guided-filter/img_feathering/toy-feather.png) 204 | 205 | 206 | ### Enhancement 207 | 208 | ```c++ 209 | cv::Mat I = cv::imread("./img_enhancement/tulips.bmp", CV_LOAD_IMAGE_COLOR); 210 | I.convertTo(I, CV_32F, 1.0 / 255.0); 211 | 212 | cv::Mat p = I; 213 | 214 | int r = 16; 215 | double eps = 0.1 * 0.1; 216 | 217 | cv::Mat q = guidedFilter(I, p, r, eps); 218 | 219 | cv::Mat I_enhanced = (I - q) * 5 + q; 220 | ``` 221 | 222 | [![Tulip](http://atilimcetin.com/guided-filter/img_enhancement/tulips-small.png)](http://atilimcetin.com/guided-filter/img_enhancement/tulips.png) 223 | [![Smoothed](http://atilimcetin.com/guided-filter/img_enhancement/tulips-smoothed-small.png)](http://atilimcetin.com/guided-filter/img_enhancement/tulips-smoothed.png) 224 | [![Enhanced](http://atilimcetin.com/guided-filter/img_enhancement/tulips-enhanced-small.png)](http://atilimcetin.com/guided-filter/img_enhancement/tulips-enhanced.png) 225 | 226 | 227 | ## License 228 | 229 | MIT license. 230 | 231 | -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:1_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:1_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:color_result_s:2_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:color_result_s:2_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:1_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:1_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/I:gray_result_s:2_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/I:gray_result_s:2_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/cat.png -------------------------------------------------------------------------------- /imgs/chian_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/chian_2.png -------------------------------------------------------------------------------- /imgs/china_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/china_1.png -------------------------------------------------------------------------------- /imgs/people.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/people.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:1_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:1_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:2_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:2_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:2_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:2_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:2_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:2_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:4_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:4_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:4_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:4_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:4_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:4_eps:0.400000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:8_eps:0.100000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:8_eps:0.100000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:8_eps:0.200000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:8_eps:0.200000^2.png -------------------------------------------------------------------------------- /imgs/result_s:2_r:8_eps:0.400000^2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/imgs/result_s:2_r:8_eps:0.400000^2.png -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "FastGuidedFilter/fastguidedfilter.h" 2 | using namespace std; 3 | using namespace cv; 4 | int main() { 5 | 6 | int R[]={2,4,8}; 7 | double EPS[]={0.1,0.2,0.4}; 8 | Mat result; 9 | for(int s=1;s<=2;++s) { 10 | for (int i = 0; i < 3; ++i) { 11 | for (int j = 0; j < 3; ++j) { 12 | //Mat P = imread("../imgs/cat.jpg", CV_LOAD_IMAGE_GRAYSCALE); 13 | Mat P = imread("../imgs/people.png", CV_LOAD_IMAGE_ANYCOLOR); 14 | Mat I; 15 | //cvtColor(P,I,CV_BGR2GRAY); 16 | I = P; 17 | int r = R[i]; 18 | float eps = EPS[j]*EPS[j]; 19 | eps *= 255 * 255; 20 | clock_t start_time1 = clock(); 21 | result = fastGuidedFilter(I, P, r, eps, s); 22 | clock_t end_time1 = clock(); 23 | cout << "fastguidedfilter Running time is: " 24 | << static_cast(end_time1 - start_time1) / CLOCKS_PER_SEC * 1000 << "ms" << endl; 25 | string name = "I:color_result_s:" + to_string(s) + "_r:" + to_string(r) + "_eps:" + to_string(EPS[j]) + "^2.png"; 26 | imwrite(name, result); 27 | } 28 | } 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /paper/Fast Guided Filter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/paper/Fast Guided Filter.pdf -------------------------------------------------------------------------------- /paper/pami12guidedfilter.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Sundrops/fast-guided-filter/47cedb5bbcfbe1ed5be1edd006106e0ab82a2eb7/paper/pami12guidedfilter.pdf --------------------------------------------------------------------------------