Created
July 21, 2022 07:31
-
-
Save jeesay/cd54a8de6900047ecf9ba4b57ac23ee9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Calc Real and Imaginary Parts of a FFT | |
* Jean-Christophe Taveau | |
* 2022/07/20 | |
*/ | |
const imp = IJ.getImage(); | |
const w = imp.getWidth(); | |
const h = imp.getHeight(); | |
// Create Output | |
const re = new FloatProcessor(w,h); | |
const im = new FloatProcessor(w,h); | |
// Calc Real and Imaginary Parts | |
const mag = imp.getImageStack().getProcessor(1); | |
const phase = imp.getImageStack().getProcessor(2); | |
for (let i = 0; i < w*h;i++) { | |
const rei = mag.getf(i) * Math.cos(phase.getf(i) ); | |
const imi = mag.getf(i) * Math.sin(phase.getf(i) ); | |
re.setf(i,rei); | |
im.setf(i,imi); | |
} | |
const stack = new ImageStack(); | |
stack.addSlice("Real",re); | |
stack.addSlice("Imaginary",im); | |
const output = new ImagePlus("Complex of Signal",stack); | |
output.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment