# Revision history [back]

Hi, I don't know why I can't access the other account I opened in Feb this year. So thanks to thudor who replied to my question in February.

Now the problem I am facing is, (I am still novice in opencv, so please bear):

1. I am taking DFT of an image.
2. From the complex output I am cropping a circular portion surrounding a set of coordinates.
3. I am doing inverse Fourier Transform of this cropped Image (the size of the cropped image is equal to the complex output of DFT).
4. Now when I take the magnitude of the IDFT its fine. But the phase is not what I get in MATLAB. I mean the pattern.

So, I tried to look at the possible troubles. When I am cropping the image, I am creating a mask.

temp = new_mask(complexI, real_center);


Mat new_mask(Mat q, max_intensity m) {

Mat masks = Mat::zeros(q.size(), CV_8U);
circle(masks, Point(m.col_ref, m.row_ref), int(filter_rad), Scalar(255, 255, 255), -1, 8, 0); //-1 means filled


}

And then using this mask I am cropping the complex matrix.

Mat cropped(complexI.size(), complexI.type(), Scalar::all(0));
complexI.copyTo(cropped, temp);


Do you think, because I used CV_8U as the type of the mask matrix it is causing trouble when I am doing inverse Fourier transform? Please suggest.

I tried using other data types like CV_64FC2 but then the sentence complexI.copyTo(cropped, temp) doesn't work. Even if I use the type complexI.type() for the masks matrix this sentence doesn't work.

I am giving an example of the comparison of phase output of IDFT in MATLAB and opencv. PLEASE HELP!!!

The blue line is MATLAB output and the red one is opencv.

THANKS A LOT IN ADVANCE whoever helps :)