# dft and normalize [closed]

one image first was processed by dft and then do a circle mask its frequency field, which means the pixel value is zero on the corner, after that, do inverse dft on it to back image. until now, every thing is OK, No problem.

but when I normailze the image and convert it to 16 bit. it is wrong. I do fft on the result image on imagej, and its corner is not zero.

normalize(clean_sf,clean_sf,0,1,CV_MINMAX); clean_sf.convertTo(result,CV_16UC1,65536);

// My question is simple, probably I did describe clear. I do some operation on frequency field(binary mask, to keep the center part, set other to zero). then back to real space.

when I do fourier transform on the result image, I find they are not zero, but lower value.

I think the problem of normalize, but I do not understand.

//////////////// I tried to upload image, but failed.

/////////////////////

I think there is a problem on DFT.

step 1. do some operation in fourier space(fig.1 is the amplitude of it).

step 2. dft back to real space

```
dft(clean_sf,clean_sf,DFT_INVERSE|DFT_REAL_OUTPUT);
```

step 3. dft back to fourier space and generate the amplitude spectrum(fig. 2)

```
void FftOperation(Mat & img, Mat & complexI){
Mat padded;
int m = getOptimalDFTSize( img.rows );
int n = getOptimalDFTSize( img.cols );
copyMakeBorder(img, padded, 0, m - img.rows, 0, n - img.cols, BORDER_CONSTANT, Scalar::all(0));
padded = Mat_<float>(padded);
Mat planes[] = {Mat_<float>(padded), Mat::zeros(padded.size(), CV_32F)};
merge(planes, 2, complexI);
dft(complexI, complexI);
complexI = complexI(Rect(0, 0, complexI.cols & -2, complexI.rows & -2));
SwitchQua(complexI);
```

}

void ShowMagnitude(string WindowName,Mat img) {

```
Mat planes[] = { Mat::zeros(img.size(),CV_32F), Mat::zeros(img.size(), CV_32F) };
//split
split(img,planes);
//magintude
magnitude(planes[0],planes[1],planes[0]);
Mat magI = planes[0];
magI += Scalar::all(1);
log(magI,magI);
normalize(magI, magI, 0, 1, CV_MINMAX);
imshow(WindowName, magI);
Mat saveImg;
magI.convertTo(saveImg, CV_8UC1,255);
imwrite(WindowName+".tif", saveImg);
```

}

fig.1 and fig.2 should the same. but it different.I mean the part out of circle in fig.2 should be zero, just like fig.1. but it is not.

fig.1

fig.2

upload your image in http://www.image-share.com/ & post the link here. Add your Code describing what you are doing.