|
|
|
@ -147,15 +147,9 @@ void Cloning::dst(const Mat& src, Mat& dest, bool invert) |
|
|
|
|
split(complex, planes2); |
|
|
|
|
|
|
|
|
|
temp = planes2[1].t(); |
|
|
|
|
dest = Mat::zeros(src.size(), CV_32F); |
|
|
|
|
temp(Rect( 0, 1, src.cols, src.rows)).copyTo(dest); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Cloning::idst(const Mat& src, Mat& dest) |
|
|
|
|
{ |
|
|
|
|
dst(src, dest, true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void Cloning::solve(const Mat &img, Mat& mod_diff, Mat &result) |
|
|
|
|
{ |
|
|
|
|
const int w = img.cols; |
|
|
|
@ -173,7 +167,7 @@ void Cloning::solve(const Mat &img, Mat& mod_diff, Mat &result) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
idst(res, mod_diff); |
|
|
|
|
dst(res, mod_diff, true); |
|
|
|
|
|
|
|
|
|
unsigned char * resLinePtr = result.ptr<unsigned char>(0); |
|
|
|
|
const unsigned char * imgLinePtr = img.ptr<unsigned char>(0); |
|
|
|
@ -221,9 +215,7 @@ void Cloning::poissonSolver(const Mat &img, Mat &laplacianX , Mat &laplacianY, M |
|
|
|
|
const int w = img.cols; |
|
|
|
|
const int h = img.rows; |
|
|
|
|
|
|
|
|
|
Mat lap = Mat(img.size(),CV_32FC1); |
|
|
|
|
|
|
|
|
|
lap = laplacianX + laplacianY; |
|
|
|
|
Mat lap = laplacianX + laplacianY; |
|
|
|
|
|
|
|
|
|
Mat bound = img.clone(); |
|
|
|
|
|
|
|
|
@ -305,11 +297,8 @@ void Cloning::arrayProduct(const cv::Mat& lhs, const cv::Mat& rhs, cv::Mat& resu |
|
|
|
|
|
|
|
|
|
void Cloning::poisson(const Mat &destination) |
|
|
|
|
{ |
|
|
|
|
Mat laplacianX = Mat(destination.size(),CV_32FC3); |
|
|
|
|
Mat laplacianY = Mat(destination.size(),CV_32FC3); |
|
|
|
|
|
|
|
|
|
laplacianX = destinationGradientX + patchGradientX; |
|
|
|
|
laplacianY = destinationGradientY + patchGradientY; |
|
|
|
|
Mat laplacianX = destinationGradientX + patchGradientX; |
|
|
|
|
Mat laplacianY = destinationGradientY + patchGradientY; |
|
|
|
|
|
|
|
|
|
computeLaplacianX(laplacianX,laplacianX); |
|
|
|
|
computeLaplacianY(laplacianY,laplacianY); |
|
|
|
@ -392,7 +381,7 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &b |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case MONOCHROME_TRANSFER: |
|
|
|
|
Mat gray = Mat(patch.size(),CV_8UC1); |
|
|
|
|
Mat gray; |
|
|
|
|
cvtColor(patch, gray, COLOR_BGR2GRAY ); |
|
|
|
|
|
|
|
|
|
computeGradientX(gray,patchGradientX); |
|
|
|
@ -429,7 +418,7 @@ void Cloning::illuminationChange(Mat &I, Mat &mask, Mat &wmask, Mat &cloned, flo |
|
|
|
|
arrayProduct(patchGradientX,binaryMaskFloat, patchGradientX); |
|
|
|
|
arrayProduct(patchGradientY,binaryMaskFloat, patchGradientY); |
|
|
|
|
|
|
|
|
|
Mat mag = Mat(I.size(),CV_32FC3); |
|
|
|
|
Mat mag; |
|
|
|
|
magnitude(patchGradientX,patchGradientY,mag); |
|
|
|
|
|
|
|
|
|
Mat multX, multY, multx_temp, multy_temp; |
|
|
|
@ -457,11 +446,10 @@ void Cloning::textureFlatten(Mat &I, Mat &mask, Mat &wmask, float low_threshold, |
|
|
|
|
{ |
|
|
|
|
computeDerivatives(I,mask,wmask); |
|
|
|
|
|
|
|
|
|
Mat out = Mat(mask.size(),CV_8UC1); |
|
|
|
|
Mat out; |
|
|
|
|
Canny(mask,out,low_threshold,high_threshold,kernel_size); |
|
|
|
|
|
|
|
|
|
Mat zeros(patchGradientX.size(), CV_32FC3); |
|
|
|
|
zeros.setTo(0); |
|
|
|
|
Mat zeros = Mat::zeros(patchGradientX.size(), CV_32FC3); |
|
|
|
|
Mat zerosMask = (out != 255); |
|
|
|
|
zeros.copyTo(patchGradientX, zerosMask); |
|
|
|
|
zeros.copyTo(patchGradientY, zerosMask); |
|
|
|
|