refactor array_product
This commit is contained in:
parent
33c15d6309
commit
b3ddc2b9a7
@ -63,7 +63,6 @@ namespace cv
|
|||||||
void init_var(const cv::Mat &I, const cv::Mat &wmask);
|
void init_var(const cv::Mat &I, const cv::Mat &wmask);
|
||||||
void compute_derivatives(const cv::Mat &I, const cv::Mat &mask, const cv::Mat &wmask);
|
void compute_derivatives(const cv::Mat &I, const cv::Mat &mask, const cv::Mat &wmask);
|
||||||
void scalar_product(cv::Mat mat, float r, float g, float b);
|
void scalar_product(cv::Mat mat, float r, float g, float b);
|
||||||
void array_product(cv::Mat mat1, cv::Mat mat2, cv::Mat mat3);
|
|
||||||
void poisson(const cv::Mat &I, const cv::Mat &gx, const cv::Mat &gy, const cv::Mat &sx, const cv::Mat &sy);
|
void poisson(const cv::Mat &I, const cv::Mat &gx, const cv::Mat &gy, const cv::Mat &sx, const cv::Mat &sy);
|
||||||
void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned);
|
void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned);
|
||||||
void dst(double *mod_diff, double *sineTransform,int h,int w);
|
void dst(double *mod_diff, double *sineTransform,int h,int w);
|
||||||
@ -72,6 +71,7 @@ namespace cv
|
|||||||
void solve(const cv::Mat &img, double *mod_diff, cv::Mat &result);
|
void solve(const cv::Mat &img, double *mod_diff, cv::Mat &result);
|
||||||
void poisson_solver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result);
|
void poisson_solver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result);
|
||||||
|
|
||||||
|
void array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const;
|
||||||
|
|
||||||
void computeGradientX(const cv::Mat &img, cv::Mat &gx);
|
void computeGradientX(const cv::Mat &img, cv::Mat &gx);
|
||||||
void computeGradientY(const cv::Mat &img, cv::Mat &gy);
|
void computeGradientY(const cv::Mat &img, cv::Mat &gy);
|
||||||
|
@ -369,16 +369,18 @@ void Cloning::scalar_product(Mat mat, float r, float g, float b)
|
|||||||
merge(channels,mat);
|
merge(channels,mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::array_product(Mat mat1, Mat mat2, Mat mat3)
|
void Cloning::array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const
|
||||||
{
|
{
|
||||||
vector <Mat> channels_temp1;
|
vector <Mat> lhs_channels;
|
||||||
vector <Mat> channels_temp2;
|
vector <Mat> result_channels;
|
||||||
split(mat1,channels_temp1);
|
|
||||||
split(mat2,channels_temp2);
|
split(lhs,lhs_channels);
|
||||||
multiply(channels_temp2[2],mat3,channels_temp1[2]);
|
split(result,result_channels);
|
||||||
multiply(channels_temp2[1],mat3,channels_temp1[1]);
|
|
||||||
multiply(channels_temp2[0],mat3,channels_temp1[0]);
|
for(int chan = 0 ; chan < 3 ; ++chan)
|
||||||
merge(channels_temp1,mat1);
|
multiply(lhs_channels[chan],rhs,result_channels[chan]);
|
||||||
|
|
||||||
|
merge(result_channels,result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::poisson(const Mat &I, const Mat &gx, const Mat &gy, const Mat &sx, const Mat &sy)
|
void Cloning::poisson(const Mat &I, const Mat &gx, const Mat &gy, const Mat &sx, const Mat &sy)
|
||||||
@ -413,8 +415,8 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
|
|||||||
I.convertTo(grx32,CV_32FC3,1.0/255.0);
|
I.convertTo(grx32,CV_32FC3,1.0/255.0);
|
||||||
I.convertTo(gry32,CV_32FC3,1.0/255.0);
|
I.convertTo(gry32,CV_32FC3,1.0/255.0);
|
||||||
|
|
||||||
array_product(grx32,grx,smask1);
|
array_product(grx,smask1, grx32);
|
||||||
array_product(gry32,gry,smask1);
|
array_product(gry,smask1, gry32);
|
||||||
|
|
||||||
poisson(I,grx32,gry32,srx32,sry32);
|
poisson(I,grx32,gry32,srx32,sry32);
|
||||||
|
|
||||||
@ -433,8 +435,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &mask, const Mat &w
|
|||||||
switch(flag)
|
switch(flag)
|
||||||
{
|
{
|
||||||
case NORMAL_CLONE:
|
case NORMAL_CLONE:
|
||||||
array_product(srx32,sgx,smask);
|
array_product(sgx,smask, srx32);
|
||||||
array_product(sry32,sgy,smask);
|
array_product(sgy,smask, sry32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MIXED_CLONE:
|
case MIXED_CLONE:
|
||||||
@ -481,8 +483,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &mask, const Mat &w
|
|||||||
computeGradientX(gray8,sgx);
|
computeGradientX(gray8,sgx);
|
||||||
computeGradientY(gray8,sgy);
|
computeGradientY(gray8,sgy);
|
||||||
|
|
||||||
array_product(srx32,sgx,smask);
|
array_product(sgx, smask, srx32);
|
||||||
array_product(sry32,sgy,smask);
|
array_product(sgy, smask, sry32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -495,8 +497,8 @@ void Cloning::local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, flo
|
|||||||
{
|
{
|
||||||
compute_derivatives(I,mask,wmask);
|
compute_derivatives(I,mask,wmask);
|
||||||
|
|
||||||
array_product(srx32,sgx,smask);
|
array_product(sgx,smask, srx32);
|
||||||
array_product(sry32,sgy,smask);
|
array_product(sgy,smask, sry32);
|
||||||
scalar_product(srx32,red_mul,green_mul,blue_mul);
|
scalar_product(srx32,red_mul,green_mul,blue_mul);
|
||||||
scalar_product(sry32,red_mul,green_mul,blue_mul);
|
scalar_product(sry32,red_mul,green_mul,blue_mul);
|
||||||
|
|
||||||
@ -507,8 +509,8 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp
|
|||||||
{
|
{
|
||||||
compute_derivatives(I,mask,wmask);
|
compute_derivatives(I,mask,wmask);
|
||||||
|
|
||||||
array_product(srx32,sgx,smask);
|
array_product(sgx,smask, srx32);
|
||||||
array_product(sry32,sgy,smask);
|
array_product(sgy,smask, sry32);
|
||||||
|
|
||||||
Mat mag = Mat(I.size(),CV_32FC3);
|
Mat mag = Mat(I.size(),CV_32FC3);
|
||||||
magnitude(srx32,sry32,mag);
|
magnitude(srx32,sry32,mag);
|
||||||
@ -545,8 +547,8 @@ void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, double low_threshol
|
|||||||
zeros.copyTo(sgx, zerosMask);
|
zeros.copyTo(sgx, zerosMask);
|
||||||
zeros.copyTo(sgy, zerosMask);
|
zeros.copyTo(sgy, zerosMask);
|
||||||
|
|
||||||
array_product(srx32,sgx,smask);
|
array_product(sgx,smask, srx32);
|
||||||
array_product(sry32,sgy,smask);
|
array_product(sgy,smask, sry32);
|
||||||
|
|
||||||
evaluate(I,wmask,cloned);
|
evaluate(I,wmask,cloned);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user