mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
Merge pull request #2375 from akarsakov:fix_getGradient
This commit is contained in:
commit
9c5bd85247
@ -79,61 +79,34 @@ class Cloning
|
|||||||
|
|
||||||
void Cloning::getGradientx( const Mat &img, Mat &gx)
|
void Cloning::getGradientx( const Mat &img, Mat &gx)
|
||||||
{
|
{
|
||||||
int w = img.size().width;
|
Mat kernel = Mat::zeros(1, 3, CV_8S);
|
||||||
int h = img.size().height;
|
kernel.at<char>(0,2) = 1;
|
||||||
int channel = img.channels();
|
kernel.at<char>(0,1) = -1;
|
||||||
for(int i=0;i<h;i++)
|
filter2D(img, gx, CV_32F, kernel);
|
||||||
for(int j=0;j<w;j++)
|
|
||||||
for(int c=0;c<channel;++c)
|
|
||||||
{
|
|
||||||
gx.at<float>(i,j*channel+c) =
|
|
||||||
(float)img.at<uchar>(i,(j+1)*channel+c) - (float)img.at<uchar>(i,j*channel+c);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::getGradienty( const Mat &img, Mat &gy)
|
void Cloning::getGradienty( const Mat &img, Mat &gy)
|
||||||
{
|
{
|
||||||
int w = img.size().width;
|
Mat kernel = Mat::zeros(3, 1, CV_8S);
|
||||||
int h = img.size().height;
|
kernel.at<char>(2,0) = 1;
|
||||||
int channel = img.channels();
|
kernel.at<char>(1,0) = -1;
|
||||||
for(int i=0;i<h;i++)
|
filter2D(img, gy, CV_32F, kernel);
|
||||||
for(int j=0;j<w;j++)
|
|
||||||
for(int c=0;c<channel;++c)
|
|
||||||
{
|
|
||||||
gy.at<float>(i,j*channel+c) =
|
|
||||||
(float)img.at<uchar>((i+1),j*channel+c) - (float)img.at<uchar>(i,j*channel+c);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::lapx( const Mat &img, Mat &gxx)
|
void Cloning::lapx( const Mat &img, Mat &gxx)
|
||||||
{
|
{
|
||||||
int w = img.size().width;
|
Mat kernel = Mat::zeros(1, 3, CV_8S);
|
||||||
int h = img.size().height;
|
kernel.at<char>(0,0) = -1;
|
||||||
int channel = img.channels();
|
kernel.at<char>(0,1) = 1;
|
||||||
for(int i=0;i<h;i++)
|
filter2D(img, gxx, CV_32F, kernel);
|
||||||
for(int j=0;j<w-1;j++)
|
|
||||||
for(int c=0;c<channel;++c)
|
|
||||||
{
|
|
||||||
gxx.at<float>(i,(j+1)*channel+c) =
|
|
||||||
(float)img.at<float>(i,(j+1)*channel+c) - (float)img.at<float>(i,j*channel+c);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::lapy( const Mat &img, Mat &gyy)
|
void Cloning::lapy( const Mat &img, Mat &gyy)
|
||||||
{
|
{
|
||||||
int w = img.size().width;
|
Mat kernel = Mat::zeros(3, 1, CV_8S);
|
||||||
int h = img.size().height;
|
kernel.at<char>(0,0) = -1;
|
||||||
int channel = img.channels();
|
kernel.at<char>(1,0) = 1;
|
||||||
for(int i=0;i<h-1;i++)
|
filter2D(img, gyy, CV_32F, kernel);
|
||||||
for(int j=0;j<w;j++)
|
|
||||||
for(int c=0;c<channel;++c)
|
|
||||||
{
|
|
||||||
gyy.at<float>(i+1,j*channel+c) =
|
|
||||||
(float)img.at<float>((i+1),j*channel+c) - (float)img.at<float>(i,j*channel+c);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cloning::dst(double *mod_diff, double *sineTransform,int h,int w)
|
void Cloning::dst(double *mod_diff, double *sineTransform,int h,int w)
|
||||||
|
Loading…
Reference in New Issue
Block a user