From 1a14d8506deb914f151063c82c109fb3ed47e30c Mon Sep 17 00:00:00 2001 From: siddharth Date: Fri, 11 Apr 2014 10:52:34 +0530 Subject: [PATCH] recursive filter output corrected --- modules/photo/src/npr.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/modules/photo/src/npr.hpp b/modules/photo/src/npr.hpp index 744b2bd..4663780 100644 --- a/modules/photo/src/npr.hpp +++ b/modules/photo/src/npr.hpp @@ -173,6 +173,7 @@ void Domain_Filter::compute_Rfilter(Mat &output, Mat &hz, float sigma_h) { int h = output.rows; int w = output.cols; + int channel = output.channels(); float a = (float) exp((-1.0 * sqrt(2.0)) / sigma_h); @@ -185,11 +186,15 @@ void Domain_Filter::compute_Rfilter(Mat &output, Mat &hz, float sigma_h) for(int j=0;j(i,j) = pow(a,hz.at(i,j)); - for(int i=0; i(i,j) = temp.at(i,j) + (temp.at(i,j-1) - temp.at(i,j)) * V.at(i,j); + for(int c = 0; c(i,j*channel+c) = temp.at(i,j*channel+c) + + (temp.at(i,(j-1)*channel+c) - temp.at(i,j*channel+c)) * V.at(i,j); + } } } @@ -197,7 +202,11 @@ void Domain_Filter::compute_Rfilter(Mat &output, Mat &hz, float sigma_h) { for(int j =w-2; j >= 0; j--) { - temp.at(i,j) = temp.at(i,j) + (temp.at(i,j+1) - temp.at(i,j)) * V.at(i,j+1); + for(int c = 0; c(i,j*channel+c) = temp.at(i,j*channel+c) + + (temp.at(i,(j+1)*channel+c) - temp.at(i,j*channel+c))*V.at(i,j+1); + } } } -- 2.7.4