private void button3_Click(object sender, EventArgs e) { //1. Create FFT Object FFT FourObj; FourObj = new FFT(bmp); FourObj.ForwardFFT();// Finding 2D FFT of Image FFT FourRef1; FourRef1 = new FFT(bmp1); FourRef1.ForwardFFT();// Finding 2D FFT of Image FFT FourRef2; FourRef2 = new FFT(bmp3); FourRef2.ForwardFFT();// Finding 2D FFT of Image FFT outTmp; outTmp = new FFT(bmp); ////////////////////////////////////////// for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { outnew[i, j].real = FourObj.Output[i, j].real * FourRef1.Output[i, j].real * FourRef2.Output[i, j].real - FourObj.Output[i, j].imag * FourRef1.Output[i, j].real * FourRef2.Output[i, j].imag + FourObj.Output[i, j].real * FourRef1.Output[i, j].imag * FourRef2.Output[i, j].imag + FourObj.Output[i, j].imag * FourRef1.Output[i, j].imag * FourRef2.Output[i, j].real; outnew[i, j].imag = FourObj.Output[i, j].real * FourRef1.Output[i, j].real * FourRef2.Output[i, j].imag + FourObj.Output[i, j].imag * FourRef1.Output[i, j].real * FourRef2.Output[i, j].real - FourObj.Output[i, j].real * FourRef1.Output[i, j].imag * FourRef2.Output[i, j].real + FourObj.Output[i, j].imag * FourRef1.Output[i, j].imag * FourRef2.Output[i, j].imag; } } outTmp.InverseFFT(outnew); // Dehologram.Image = (Image)ImgFFT.Obj; int[,] FFTNormalized = new int[256, 256]; double max = (outnew[0, 0].real * outnew[0, 0].real + outnew[0, 0].imag * outnew[0, 0].imag); for (int i = 0; i <= 255; i++) { for (int j = 0; j <= 255; j++) { if ((outnew[i, j].real * outnew[i, j].real + outnew[i, j].imag * outnew[i, j].imag) > max)//Math.Log { max = (outnew[i, j].real * outnew[i, j].real + outnew[i, j].imag * outnew[i, j].imag); } } } for (int i = 0; i <= 255; i++) { for (int j = 0; j <= 255; j++) { /* FFTLog[i, j] = FFTLog[i, j] / max; * } * for (i = 0; i <= Width - 1; i++) * for (j = 0; j <= Height - 1; j++) * {*/ FFTNormalized[i, j] = (int)(255 * (outnew[i, j].real * outnew[i, j].real + outnew[i, j].imag * outnew[i, j].imag) / max); } } //Transferring Image to Fourier Plot // FourierPlot = Displayimage(FFTNormalized); Dehologram.Image = (Image)ImgFFT.Displayimage(FFTNormalized); //////////////////////////////////////////////// }
/// <summary> /// Finding Forward FFT of Selected Bitmap /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button1_Click(object sender, EventArgs e) { //1. Create FFT Object ImgFFT = new FFT(bmp); ImgFFT.ForwardFFT(); // Finding 2D FFT of Image ImgFFT.FFTShift(); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { Out1[i, j] = ImgFFT.FFTShifted[i, j]; // OutReal[i, j] = (int)ImgFFT.FFTShifted[i, j].real; // OutImag[i, j] = (int)ImgFFT.FFTShifted[i, j].imag; } } ImgFFT.FFTPlot(ImgFFT.FFTShifted); //ImgFFT.InverseFFT(); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { M1[i, j] = ImgFFT.PhasePlot1[i, j]; P1[i, j] = ImgFFT.MagniturePlot1[i, j]; } } furiebox1.Image = (Image)ImgFFT.Displayimage(P1); // Dehologram.Image = (Image)ImgFFT.Obj; // Dehologram.Image = (Image)ImgFFT.Displayimage(OutReal); //furiebox1.Image = (Image)ImgFFT.Displayimage(OutImag); ImgFFT = new FFT(bmp1); ImgFFT.ForwardFFT();// Finding 2D FFT of Image ImgFFT.FFTShift(); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { Out2[i, j] = ImgFFT.FFTShifted[i, j]; } } ImgFFT.FFTPlot(ImgFFT.FFTShifted); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { M2[i, j] = ImgFFT.PhasePlot1[i, j]; P2[i, j] = ImgFFT.MagniturePlot1[i, j]; } } furiebox2.Image = (Image)ImgFFT.Displayimage(P2); ImgFFT = new FFT(bmp3); ImgFFT.ForwardFFT();// Finding 2D FFT of Image ImgFFT.FFTShift(); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { Out3[i, j] = ImgFFT.FFTShifted[i, j]; } } ImgFFT.FFTPlot(ImgFFT.FFTShifted); for (int i = 0; i < 255; i++) { for (int j = 0; j < 255; j++) { keyP[i, j] = ImgFFT.PhasePlot1[i, j]; keyM[i, j] = ImgFFT.MagniturePlot1[i, j]; } } kMag.Image = (Image)ImgFFT.Displayimage(keyM); }