Created
October 7, 2014 01:51
-
-
Save abak/5f39cdf2eee00025f31c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void Cloning::dst(const std::vector<double>& mod_diff, std::vector<double>& sineTransform,int h,int w) | |
{ | |
unsigned long int idx; | |
Mat temp = Mat(2*h+2,1,CV_32F); | |
Mat res = Mat(h,1,CV_32F); | |
Mat planes[] = {Mat_<float>(temp), Mat::zeros(temp.size(), CV_32F)}; | |
Mat result; | |
int p=0; | |
const double factor = 0.5; | |
for(int i=0;i<w;i++) | |
{ | |
temp.at<float>(0,0) = 0.0; | |
for(int j=0,r=1;j<h;j++,r++) | |
{ | |
idx = j*w+i; | |
temp.at<float>(r,0) = (float) mod_diff[idx]; | |
} | |
temp.at<float>(h+1,0)=0.0; | |
for(int j=h-1, r=h+2;j>=0;j--,r++) | |
{ | |
idx = j*w+i; | |
temp.at<float>(r,0) = (float) (-1.0 * mod_diff[idx]); | |
} | |
merge(planes, 2, result); | |
dft(result,result,0,0); | |
Mat planes1[] = {Mat::zeros(result.size(), CV_32F), Mat::zeros(result.size(), CV_32F)}; | |
split(result, planes1); | |
for(int c=1,z=0;c<h+1;c++,z++) | |
{ | |
res.at<float>(z,0) = (float) (planes1[1].at<float>(c,0) * factor); | |
} | |
for(int q=0,z=0;q<h;q++,z++) | |
{ | |
idx = q*w + p; | |
sineTransform[idx] = res.at<float>(z,0); | |
} | |
p++; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment