dft and normalize [closed]

asked 2014-07-23 04:47:25 -0500

lyw8120 gravatar image

updated 2014-09-04 08:36:46 -0500

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


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));



void ShowMagnitude(string WindowName,Mat img) {

Mat planes[] = { Mat::zeros(img.size(),CV_32F), Mat::zeros(img.size(), CV_32F) };   


Mat magI = planes[0];

magI += Scalar::all(1);

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 image description

fig.2 image description

edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by lyw8120
close date 2015-01-20 04:33:01.510805


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

Balaji R gravatar imageBalaji R ( 2014-07-24 06:35:24 -0500 )edit