0
我使用FFT創建的圖像與IFFT相比,有問題。這是我正在轉換的圖像:oryginal image,以下是我在FFT和IFFT後獲得的圖像:output image。我認爲相轉換是好的,問題在於大小轉換。下面是對每個像素中環紅色通道我FFT功能的一部分,OUTR從fftw_plan_dft_2d功能輸出和magRMax是所有大小的maxiumum值:在IFT中使用QT C++中的FFTW庫模糊圖像
realR = outR[tempCounter][0]/(double)(squareSize * squareSize);
imagR = outR[tempCounter][1]/(double)(squareSize * squareSize);
...
magR = sqrt((realR * realR) + (imagR * imagR));
...
int param = 255;
magR = (param*log(magR+1))/log(1 + magRMax);
...
magR = (magR > 255 ? 255 : magR);
...
magR = (magR < 0 ? 0 : magR);
...
tempColor.setRed((int)magR);
新的像素被分配到幅度圖像。經過FFT和創建幅度,我試圖做IFFT沒有任何幅度,相位圖像的任何中期變化的相位圖像。下面是用於紅色chanell我的IFFT功能的一部分:
planR = fftw_plan_dft_2d(squareSize, squareSize, inR, outR, FFTW_BACKWARD, FFTW_ESTIMATE);
...
tempColor.setRgb(myImageMag->pixel(i,j));
tempColor2.setRgb(myImagePhase->pixel(i,j));
magR = tempColor.red()/255.0;
phaseR = ((tempColor2.red()/255.0) * 2 * M_PI) - M_PI;
inR[tempCounter][0] = (magR * cos(phaseR));
inR[tempCounter][1] = (magR * sin(phaseR));
...
redMax += abs(redMin);
...
red = (int)(outR[tempCounter][0]);
...
red = ((red + abs(redMin))/(double)redMax)*255.0;
...
tempColor.setRed(red);
的RedMAX是OUTR的所有像素的最大值[tempCounter] [0],redMin是OUTR的所有像素的最小值[tempCounter] [0]。 redMax + = abs(redMin)是縮小的過程,因爲我得到的值低於0,我也調整了所有的紅色值。
代碼以在GitHub進行編程:
https://github.com/Hariver/POID/blob/master/main.cpp