import ij.*; import ij.plugin.filter.PlugInFilter; import ij.process.*; import java.awt.*; /* Compute the 3D Fast Harley Transform of a 32-bit image stack. The width and height of the images must be powers of 2. The need not match. The number of slices is not restricted, but a slow transform technique is used if the number of slices is not a power of 2. The normalization is such that the forward and inverse transforms are performed by the same plugin. Bob Dougherty Version 0 4/24/2005. Version 0.1 4/25/2005 Explicitly redraw the image upon completion. Much is the code is from FFT_Filter by Joachim Walter. Some items are from the related FHT by Wayne Rasband. The following notice is from the FHT source code in ImageJ: This class contains a Java implementation of the Fast Hartley Transform. It is based on Pascal code in NIH Image contributed by Arlo Reeves (http://rsb.info.nih.gov/ij/docs/ImageFFT/). The Fast Hartley Transform was restricted by U.S. Patent No. 4,646,256, but was placed in the public domain by Stanford University in 1995 and is now freely available. */ public class FHT_3D implements PlugInFilter { private ImagePlus imp; public int setup(String arg, ImagePlus imp) { IJ.register(FHT_3D.class); this.imp = imp; return DOES_32; } public void run(ImageProcessor ip) { ImageStack stack = imp.getStack(); int w = stack.getWidth(); int h = stack.getHeight(); if(!(powerOf2Size(w)&&powerOf2Size(h))){ IJ.error("The width and height must be powers of 2."); return; } int d = imp.getStackSize(); float[][] data = new float[d][]; for (int i = 0; i < d; i++){ data[i] = (float[])stack.getProcessor(i+1).getPixels(); } FHT3D(data,w,h,d); imp.updateAndDraw(); } boolean powerOf2Size(int w) { int i=2; while(i 2) { // third + stages computed here gpSize = 4; numBfs = 2; numGps = numGps / 2; //IJ.write("FFT: dfht3 "+Nlog2+" "+numGps+" "+numBfs); for (stage=2; stage 2 */ } int log2 (int x) { int count = 15; while (!btst(x, count)) count--; return count; } private boolean btst (int x, int bit) { //int mask = 1; return ((x & (1<