remove unnecessary buffer copies
This commit is contained in:
parent
b4504639c8
commit
419450689b
@ -50,7 +50,20 @@ void Cloning::computeGradientX( const Mat &img, Mat &gx)
|
||||
Mat kernel = Mat::zeros(1, 3, CV_8S);
|
||||
kernel.at<char>(0,2) = 1;
|
||||
kernel.at<char>(0,1) = -1;
|
||||
filter2D(img, gx, CV_32F, kernel);
|
||||
|
||||
if(img.channels() == 3)
|
||||
{
|
||||
filter2D(img, gx, CV_32F, kernel);
|
||||
}
|
||||
else if (img.channels() == 1)
|
||||
{
|
||||
Mat tmp[3];
|
||||
for(int chan = 0 ; chan < 3 ; ++chan)
|
||||
{
|
||||
filter2D(img, tmp[chan], CV_32F, kernel);
|
||||
}
|
||||
merge(tmp, 3, gx);
|
||||
}
|
||||
}
|
||||
|
||||
void Cloning::computeGradientY( const Mat &img, Mat &gy)
|
||||
@ -58,7 +71,20 @@ void Cloning::computeGradientY( const Mat &img, Mat &gy)
|
||||
Mat kernel = Mat::zeros(3, 1, CV_8S);
|
||||
kernel.at<char>(2,0) = 1;
|
||||
kernel.at<char>(1,0) = -1;
|
||||
filter2D(img, gy, CV_32F, kernel);
|
||||
|
||||
if(img.channels() == 3)
|
||||
{
|
||||
filter2D(img, gy, CV_32F, kernel);
|
||||
}
|
||||
else if (img.channels() == 1)
|
||||
{
|
||||
Mat tmp[3];
|
||||
for(int chan = 0 ; chan < 3 ; ++chan)
|
||||
{
|
||||
filter2D(img, tmp[chan], CV_32F, kernel);
|
||||
}
|
||||
merge(tmp, 3, gy);
|
||||
}
|
||||
}
|
||||
|
||||
void Cloning::computeLaplacianX( const Mat &img, Mat &laplacianX)
|
||||
@ -365,18 +391,10 @@ void Cloning::normalClone(const Mat &destination, const Mat &patch, const Mat &b
|
||||
|
||||
case MONOCHROME_TRANSFER:
|
||||
Mat gray = Mat(patch.size(),CV_8UC1);
|
||||
Mat gray8 = Mat(patch.size(),CV_8UC3);
|
||||
cvtColor(patch, gray, COLOR_BGR2GRAY );
|
||||
vector <Mat> temp;
|
||||
split(destination,temp);
|
||||
gray.copyTo(temp[2]);
|
||||
gray.copyTo(temp[1]);
|
||||
gray.copyTo(temp[0]);
|
||||
|
||||
merge(temp,gray8);
|
||||
|
||||
computeGradientX(gray8,patchGradientX);
|
||||
computeGradientY(gray8,patchGradientY);
|
||||
computeGradientX(gray,patchGradientX);
|
||||
computeGradientY(gray,patchGradientY);
|
||||
|
||||
arrayProduct(patchGradientX, binaryMaskFloat, patchGradientX);
|
||||
arrayProduct(patchGradientY, binaryMaskFloat, patchGradientY);
|
||||
|
Loading…
x
Reference in New Issue
Block a user