gpt4 book ai didi

java - ImageJ 图像上的矩形部分不进行 FFT

转载 作者:行者123 更新时间:2023-12-01 12:41:55 28 4
gpt4 key购买 nike

因此,除了 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;
}

最佳答案

根本问题是,如何对任意维度的输入使用以 2 为基数的傅里叶变换例程,是 actually answered on Math.SE 。如果您想要精确非2次幂的DFT结果,它并不像填充和截断那么简单。

关于java - ImageJ 图像上的矩形部分不进行 FFT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25025927/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com