【发布时间】:2014-07-30 06:37:37
【问题描述】:
因此,除了 ImageJ 之外,我还构建了自己的 FFT 算法,它对图像执行 FFT,但是当我选择图像的某个区域(使用矩形选择工具)时,它不会执行 FFT。如果选择大小是 2 的幂(如选择高度和宽度假设为 128),它会对其进行 FFT。无论选择大小如何,我都希望完成 FFT。因此,我想将数组大小增加到 2 的幂并填充它,但我不知道将其增加到什么大小以及用什么填充它。任何帮助,将不胜感激。
这是我的代码(它检查图像宽度、高度的大小,然后获取像素)。该函数位于 FHT 类中:
public void fftTransform(int w){
maxN = w;
//check if the matrix is of size of power of 2. If not then display an error.
this.widthSize = w;
largeNum = (int)(Math.log(widthSize) / Math.log(2)); //if width=256, then temp =8
if(widthSize != (1<<largeNum)){ // "<<" signed left shift operator so it creates the number 256, and checks if the width is 256 or not (because it is a power of 2).
String message = "The image size is not a power of 2. Please change image size in Image -> resize";
JOptionPane.showMessageDialog(new JFrame(), message, "Error in overlapping images",JOptionPane.ERROR_MESSAGE);
throw new IllegalArgumentException("Image is not a power of 2, fix width and height size of matrix");
}
//get the data of the original image (pixel data).
float[] fht = (float[])getPixels(); //fht is variable that maybe inherited and the name cannot change or the program will not work
Transform3D transform = new Transform3D(fht);
ComputeClassicalFFT myFFT = new ComputeClassicalFFT();
finalArray = myFFT.fft(fht, false);
isFrequencyDomain = !false;
}
【问题讨论】: