मैं http://www.fftw.org/ से लाइब्रेरी का उपयोग कर एक छवि को एफएफटी करने की कोशिश कर रहा हूं ताकि मैं आवृत्ति डोमेन में एक रूपांतरण कर सकूं। लेकिन मैं यह नहीं समझ सकता कि इसे कैसे काम करना है। यह समझने के लिए कि मैं कैसे एक छवि को पिक्सेल रंगों की एक सरणी के रूप में एफएफटी अग्रेषित करने की कोशिश कर रहा हूं और उसके बाद पिक्सेल रंगों की एक ही सरणी प्राप्त करने के लिए पिछड़ा एफएफटी। यहाँ मैं क्या करना है:फॉरवर्ड एफएफटी एक छवि और पिछड़ा एफएफटी एक ही परिणाम प्राप्त करने के लिए एक छवि
fftw_plan planR, planG, planB;
fftw_complex *inR, *inG, *inB, *outR, *outG, *outB, *resultR, *resultG, *resultB;
//Allocate arrays.
inR = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
inG = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
inB = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
outR = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
outG = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
outB = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
resultR = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
resultG = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
resultB = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * width * width);
//Fill in arrays with the pixelcolors.
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int currentIndex = ((y * width) + (x)) * 3;
inR[y * width + x][0] = pixelColors[currentIndex];
inG[y * width + x][0] = pixelColors[currentIndex + 1];
inB[y * width + x][0] = pixelColors[currentIndex + 2];
}
}
//Forward plans.
planR = fftw_plan_dft_2d(width, width, inR, outR, FFTW_FORWARD, FFTW_MEASURE);
planG = fftw_plan_dft_2d(width, width, inG, outG, FFTW_FORWARD, FFTW_MEASURE);
planB = fftw_plan_dft_2d(width, width, inB, outB, FFTW_FORWARD, FFTW_MEASURE);
//Forward FFT.
fftw_execute(planR);
fftw_execute(planG);
fftw_execute(planB);
//Backward plans.
planR = fftw_plan_dft_2d(width, width, outR, resultR, FFTW_BACKWARD, FFTW_MEASURE);
planG = fftw_plan_dft_2d(width, width, outG, resultG, FFTW_BACKWARD, FFTW_MEASURE);
planB = fftw_plan_dft_2d(width, width, outB, resultB, FFTW_BACKWARD, FFTW_MEASURE);
//Backward fft
fftw_execute(planR);
fftw_execute(planG);
fftw_execute(planB);
//Overwrite the pixelcolors with the result.
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
int currentIndex = ((y * width) + (x)) * 3;
pixelColors[currentIndex] = resultR[y * width + x][0];
pixelColors[currentIndex + 1] = resultG[y * width + x][0];
pixelColors[currentIndex + 2] = resultB[y * width + x][0];
}
}
कोई मुझे कैसे FFT एक छवि और फिर पिछड़े FFT FFTW का उपयोग कर एक ही परिणाम प्राप्त करने के लिए छवि को अग्रेषित करने का एक उदाहरण दिखा सकते हैं? मैं कई उदाहरण देख रहा हूं कि एफएफटीडब्ल्यू को एफएफटी में कैसे उपयोग किया जाए, लेकिन मैं यह नहीं समझ सकता कि यह मेरी स्थिति पर कैसे लागू होता है जहां मेरे पास छवि का प्रतिनिधित्व करने वाले पिक्सेल रंगों की एक श्रृंखला है।