From e8c2f2ee3ececd0183c3b14b203377730301c315 Mon Sep 17 00:00:00 2001 From: Adrien BAK Date: Fri, 26 Sep 2014 15:32:35 +0900 Subject: [PATCH] constness --- modules/photo/src/seamless_cloning.cpp | 6 ++--- modules/photo/src/seamless_cloning.hpp | 33 +++++++++++++++----------- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/modules/photo/src/seamless_cloning.cpp b/modules/photo/src/seamless_cloning.cpp index 445c6dae74..4761b4cdd0 100644 --- a/modules/photo/src/seamless_cloning.cpp +++ b/modules/photo/src/seamless_cloning.cpp @@ -50,9 +50,9 @@ using namespace cv; void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point p, OutputArray _blend, int flags) { - Mat src = _src.getMat(); - Mat dest = _dst.getMat(); - Mat mask = _mask.getMat(); + const Mat src = _src.getMat(); + const Mat dest = _dst.getMat(); + const Mat mask = _mask.getMat(); _blend.create(dest.size(), CV_8UC3); Mat blend = _blend.getMat(); diff --git a/modules/photo/src/seamless_cloning.hpp b/modules/photo/src/seamless_cloning.hpp index f0713ceb2e..f500ba15ba 100644 --- a/modules/photo/src/seamless_cloning.hpp +++ b/modules/photo/src/seamless_cloning.hpp @@ -51,17 +51,22 @@ using namespace cv; class Cloning { - public: + void normal_clone(const Mat &I, const Mat &mask, const Mat &wmask, Mat &cloned, int num); + void illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alpha, float beta); + void local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float red_mul, float green_mul, float blue_mul); + void texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshold, double high_threhold, int kernel_size, Mat &cloned); + + protected: vector rgb_channel, rgbx_channel, rgby_channel, output; Mat grx, gry, sgx, sgy, srx32, sry32, grx32, gry32, smask, smask1; - void init_var(Mat &I, Mat &wmask); - void initialization(Mat &I, Mat &mask, Mat &wmask); + void init_var(const Mat &I, const Mat &wmask); + void initialization(const Mat &I, const Mat &mask, const Mat &wmask); void scalar_product(Mat mat, float r, float g, float b); void array_product(Mat mat1, Mat mat2, Mat mat3); - void poisson(Mat &I, Mat &gx, Mat &gy, Mat &sx, Mat &sy); - void evaluate(Mat &I, Mat &wmask, Mat &cloned); + void poisson(const Mat &I, const Mat &gx, const Mat &gy, const Mat &sx, const Mat &sy); + void evaluate(const Mat &I, const Mat &wmask, const Mat &cloned); void getGradientx(const Mat &img, Mat &gx); void getGradienty(const Mat &img, Mat &gy); void lapx(const Mat &img, Mat &gxx); @@ -71,10 +76,10 @@ class Cloning void transpose(double *mat, double *mat_t,int h,int w); void solve(const Mat &img, double *mod_diff, Mat &result); void poisson_solver(const Mat &img, Mat &gxx , Mat &gyy, Mat &result); - void normal_clone(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, int num); - void local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float red_mul, float green_mul, float blue_mul); - void illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alpha, float beta); - void texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshold, double high_threhold, int kernel_size, Mat &cloned); + + + + }; void Cloning::getGradientx( const Mat &img, Mat &gx) @@ -352,7 +357,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &gxx , Mat &gyy, Mat &result) delete [] boundary_point; } -void Cloning::init_var(Mat &I, Mat &wmask) +void Cloning::init_var(const Mat &I, const Mat &wmask) { grx = Mat(I.size(),CV_32FC3); gry = Mat(I.size(),CV_32FC3); @@ -369,7 +374,7 @@ void Cloning::init_var(Mat &I, Mat &wmask) gry32 = Mat(I.size(),CV_32FC3); } -void Cloning::initialization(Mat &I, Mat &mask, Mat &wmask) +void Cloning::initialization(const Mat &I, const Mat &mask, const Mat &wmask) { init_var(I,wmask); @@ -411,7 +416,7 @@ void Cloning::array_product(Mat mat1, Mat mat2, Mat mat3) merge(channels_temp1,mat1); } -void Cloning::poisson(Mat &I, Mat &gx, Mat &gy, Mat &sx, Mat &sy) +void Cloning::poisson(const Mat &I, const Mat &gx, const Mat &gy, const Mat &sx, const Mat &sy) { Mat fx = Mat(I.size(),CV_32FC3); Mat fy = Mat(I.size(),CV_32FC3); @@ -435,7 +440,7 @@ void Cloning::poisson(Mat &I, Mat &gx, Mat &gy, Mat &sx, Mat &sy) poisson_solver(rgb_channel[0],rgbx_channel[0], rgby_channel[0],output[0]); } -void Cloning::evaluate(Mat &I, Mat &wmask, Mat &cloned) +void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned) { bitwise_not(wmask,wmask); @@ -451,7 +456,7 @@ void Cloning::evaluate(Mat &I, Mat &wmask, Mat &cloned) merge(output,cloned); } -void Cloning::normal_clone(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, int num) +void Cloning::normal_clone(const Mat &I, const Mat &mask, const Mat &wmask, Mat &cloned, int num) { int w = I.size().width; int h = I.size().height;