coding guidelines
This commit is contained in:
@@ -116,7 +116,7 @@ void cv::seamlessClone(InputArray _src, InputArray _dst, InputArray _mask, Point
|
||||
|
||||
|
||||
Cloning obj;
|
||||
obj.normal_clone(dest,cd_mask,dst_mask,blend,flags);
|
||||
obj.normalClone(dest,cd_mask,dst_mask,blend,flags);
|
||||
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ void cv::colorChange(InputArray _src, InputArray _mask, OutputArray _dst, float
|
||||
src.copyTo(cs_mask,gray);
|
||||
|
||||
Cloning obj;
|
||||
obj.local_color_change(src,cs_mask,gray,blend,red,green,blue);
|
||||
obj.localColorChange(src,cs_mask,gray,blend,red,green,blue);
|
||||
}
|
||||
|
||||
void cv::illuminationChange(InputArray _src, InputArray _mask, OutputArray _dst, float a, float b)
|
||||
@@ -168,7 +168,7 @@ void cv::illuminationChange(InputArray _src, InputArray _mask, OutputArray _dst,
|
||||
src.copyTo(cs_mask,gray);
|
||||
|
||||
Cloning obj;
|
||||
obj.illum_change(src,cs_mask,gray,blend,alpha,beta);
|
||||
obj.illuminationChange(src,cs_mask,gray,blend,alpha,beta);
|
||||
|
||||
}
|
||||
|
||||
@@ -193,5 +193,5 @@ void cv::textureFlattening(InputArray _src, InputArray _mask, OutputArray _dst,
|
||||
src.copyTo(cs_mask,gray);
|
||||
|
||||
Cloning obj;
|
||||
obj.texture_flatten(src,cs_mask,gray,low_threshold,high_threshold,kernel_size,blend);
|
||||
obj.textureFlatten(src,cs_mask,gray,low_threshold,high_threshold,kernel_size,blend);
|
||||
}
|
||||
|
||||
@@ -53,24 +53,24 @@ namespace cv
|
||||
class Cloning
|
||||
{
|
||||
public:
|
||||
void normal_clone(const cv::Mat& destination, const cv::Mat &mask, const cv::Mat &wmask, cv::Mat &cloned, int flag);
|
||||
void illum_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float alpha, float beta);
|
||||
void local_color_change(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float red_mul, float green_mul, float blue_mul);
|
||||
void texture_flatten(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, float low_threshold, float high_threhold, int kernel_size, cv::Mat &cloned);
|
||||
void normalClone(const cv::Mat& destination, const cv::Mat &mask, const cv::Mat &wmask, cv::Mat &cloned, int flag);
|
||||
void illuminationChange(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float alpha, float beta);
|
||||
void localColorChange(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, cv::Mat &cloned, float red_mul, float green_mul, float blue_mul);
|
||||
void textureFlatten(cv::Mat &I, cv::Mat &mask, cv::Mat &wmask, float low_threshold, float high_threhold, int kernel_size, cv::Mat &cloned);
|
||||
|
||||
protected:
|
||||
|
||||
void init_var(const cv::Mat &destination, const cv::Mat &binaryMask);
|
||||
void compute_derivatives(const cv::Mat &destination, const cv::Mat &patch, const cv::Mat &binaryMask);
|
||||
void scalar_product(cv::Mat mat, float r, float g, float b);
|
||||
void initVariables(const cv::Mat &destination, const cv::Mat &binaryMask);
|
||||
void computeDerivatives(const cv::Mat &destination, const cv::Mat &patch, const cv::Mat &binaryMask);
|
||||
void scalarProduct(cv::Mat mat, float r, float g, float b);
|
||||
void poisson(const cv::Mat &destination);
|
||||
void evaluate(const cv::Mat &I, const cv::Mat &wmask, const cv::Mat &cloned);
|
||||
void dst(const Mat& src, Mat& dest, bool invert = false);
|
||||
void idst(const Mat& src, Mat& dest);
|
||||
void solve(const cv::Mat &img, std::vector<float>& mod_diff, cv::Mat &result);
|
||||
void poisson_solver(const cv::Mat &img, cv::Mat &gxx , cv::Mat &gyy, cv::Mat &result);
|
||||
void poissonSolver(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 arrayProduct(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const;
|
||||
|
||||
void computeGradientX(const cv::Mat &img, cv::Mat &gx);
|
||||
void computeGradientY(const cv::Mat &img, cv::Mat &gy);
|
||||
|
||||
@@ -185,7 +185,7 @@ void Cloning::solve(const Mat &img, std::vector<float>& mod_diff, Mat &result)
|
||||
|
||||
}
|
||||
|
||||
void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY, Mat &result)
|
||||
void Cloning::poissonSolver(const Mat &img, Mat &laplacianX , Mat &laplacianY, Mat &result)
|
||||
{
|
||||
|
||||
const int w = img.size().width;
|
||||
@@ -237,7 +237,7 @@ void Cloning::poisson_solver(const Mat &img, Mat &laplacianX , Mat &laplacianY,
|
||||
solve(img,mod_diff,result);
|
||||
}
|
||||
|
||||
void Cloning::init_var(const Mat &destination, const Mat &binaryMask)
|
||||
void Cloning::initVariables(const Mat &destination, const Mat &binaryMask)
|
||||
{
|
||||
destinationGradientX = Mat(destination.size(),CV_32FC3);
|
||||
destinationGradientY = Mat(destination.size(),CV_32FC3);
|
||||
@@ -247,7 +247,7 @@ void Cloning::init_var(const Mat &destination, const Mat &binaryMask)
|
||||
binaryMaskFloat = Mat(binaryMask.size(),CV_32FC1);
|
||||
binaryMaskFloatInverted = Mat(binaryMask.size(),CV_32FC1);
|
||||
|
||||
//init of the filters used in the dft
|
||||
//init of the filters used in the dst
|
||||
const int w = destination.size().width;
|
||||
filter_X.resize(w - 2);
|
||||
for(int i = 0 ; i < w-2 ; ++i)
|
||||
@@ -259,9 +259,9 @@ void Cloning::init_var(const Mat &destination, const Mat &binaryMask)
|
||||
filter_Y[j] = 2.0f * std::cos(CV_PI * (j + 1) / (h - 1));
|
||||
}
|
||||
|
||||
void Cloning::compute_derivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask)
|
||||
void Cloning::computeDerivatives(const Mat& destination, const Mat &patch, const Mat &binaryMask)
|
||||
{
|
||||
init_var(destination,binaryMask);
|
||||
initVariables(destination,binaryMask);
|
||||
|
||||
computeGradientX(destination,destinationGradientX);
|
||||
computeGradientY(destination,destinationGradientY);
|
||||
@@ -276,7 +276,7 @@ void Cloning::compute_derivatives(const Mat& destination, const Mat &patch, cons
|
||||
binaryMask.convertTo(binaryMaskFloat,CV_32FC1,1.0/255.0);
|
||||
}
|
||||
|
||||
void Cloning::scalar_product(Mat mat, float r, float g, float b)
|
||||
void Cloning::scalarProduct(Mat mat, float r, float g, float b)
|
||||
{
|
||||
vector <Mat> channels;
|
||||
split(mat,channels);
|
||||
@@ -286,7 +286,7 @@ void Cloning::scalar_product(Mat mat, float r, float g, float b)
|
||||
merge(channels,mat);
|
||||
}
|
||||
|
||||
void Cloning::array_product(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const
|
||||
void Cloning::arrayProduct(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& result) const
|
||||
{
|
||||
vector <Mat> lhs_channels;
|
||||
vector <Mat> result_channels;
|
||||
@@ -318,7 +318,7 @@ void Cloning::poisson(const Mat &destination)
|
||||
|
||||
for(int chan = 0 ; chan < 3 ; ++chan)
|
||||
{
|
||||
poisson_solver(output[chan], rgbx_channel[chan], rgby_channel[chan], output[chan]);
|
||||
poissonSolver(output[chan], rgbx_channel[chan], rgby_channel[chan], output[chan]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,27 +328,27 @@ void Cloning::evaluate(const Mat &I, const Mat &wmask, const Mat &cloned)
|
||||
|
||||
wmask.convertTo(binaryMaskFloatInverted,CV_32FC1,1.0/255.0);
|
||||
|
||||
array_product(destinationGradientX,binaryMaskFloatInverted, destinationGradientX);
|
||||
array_product(destinationGradientY,binaryMaskFloatInverted, destinationGradientY);
|
||||
arrayProduct(destinationGradientX,binaryMaskFloatInverted, destinationGradientX);
|
||||
arrayProduct(destinationGradientY,binaryMaskFloatInverted, destinationGradientY);
|
||||
|
||||
poisson(I);
|
||||
|
||||
merge(output,cloned);
|
||||
}
|
||||
|
||||
void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &binaryMask, Mat &cloned, int flag)
|
||||
void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &binaryMask, Mat &cloned, int flag)
|
||||
{
|
||||
int w = destination.size().width;
|
||||
int h = destination.size().height;
|
||||
int channel = destination.channels();
|
||||
|
||||
compute_derivatives(destination,patch,binaryMask);
|
||||
computeDerivatives(destination,patch,binaryMask);
|
||||
|
||||
switch(flag)
|
||||
{
|
||||
case NORMAL_CLONE:
|
||||
array_product(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
array_product(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
break;
|
||||
|
||||
case MIXED_CLONE:
|
||||
@@ -395,8 +395,8 @@ void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &
|
||||
computeGradientX(gray8,patchGradientX);
|
||||
computeGradientY(gray8,patchGradientY);
|
||||
|
||||
array_product(patchGradientX, binaryMaskFloat, patchGradientX);
|
||||
array_product(patchGradientY, binaryMaskFloat, patchGradientY);
|
||||
arrayProduct(patchGradientX, binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY, binaryMaskFloat, patchGradientY);
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -404,25 +404,25 @@ void Cloning::normal_clone(const Mat &destination, const Mat &patch, const Mat &
|
||||
evaluate(destination,binaryMask,cloned);
|
||||
}
|
||||
|
||||
void Cloning::local_color_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float red_mul=1.0,
|
||||
void Cloning::localColorChange(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float red_mul=1.0,
|
||||
float green_mul=1.0, float blue_mul=1.0)
|
||||
{
|
||||
compute_derivatives(I,mask,wmask);
|
||||
computeDerivatives(I,mask,wmask);
|
||||
|
||||
array_product(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
array_product(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
scalar_product(patchGradientX,red_mul,green_mul,blue_mul);
|
||||
scalar_product(patchGradientY,red_mul,green_mul,blue_mul);
|
||||
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
scalarProduct(patchGradientX,red_mul,green_mul,blue_mul);
|
||||
scalarProduct(patchGradientY,red_mul,green_mul,blue_mul);
|
||||
|
||||
evaluate(I,wmask,cloned);
|
||||
}
|
||||
|
||||
void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alpha, float beta)
|
||||
void Cloning::illuminationChange(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alpha, float beta)
|
||||
{
|
||||
compute_derivatives(I,mask,wmask);
|
||||
computeDerivatives(I,mask,wmask);
|
||||
|
||||
array_product(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
array_product(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
|
||||
Mat mag = Mat(I.size(),CV_32FC3);
|
||||
magnitude(patchGradientX,patchGradientY,mag);
|
||||
@@ -447,10 +447,10 @@ void Cloning::illum_change(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, float alp
|
||||
evaluate(I,wmask,cloned);
|
||||
}
|
||||
|
||||
void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold,
|
||||
void Cloning::textureFlatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold,
|
||||
float high_threshold, int kernel_size, Mat &cloned)
|
||||
{
|
||||
compute_derivatives(I,mask,wmask);
|
||||
computeDerivatives(I,mask,wmask);
|
||||
|
||||
Mat out = Mat(mask.size(),CV_8UC1);
|
||||
Canny(mask,out,low_threshold,high_threshold,kernel_size);
|
||||
@@ -461,8 +461,8 @@ void Cloning::texture_flatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold
|
||||
zeros.copyTo(patchGradientX, zerosMask);
|
||||
zeros.copyTo(patchGradientY, zerosMask);
|
||||
|
||||
array_product(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
array_product(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY);
|
||||
|
||||
evaluate(I,wmask,cloned);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user