【问题标题】:Rectangular section on ImageJ image does not do FFTImageJ 图像上的矩形部分不执行 FFT
【发布时间】: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; 
}

【问题讨论】:

    标签: java fft imagej


    【解决方案1】:

    基本问题是actually answered on Math.SE。如果您想要精确 non-power-of-2 DFT 结果,它并不像填充和截断那么简单。

    【讨论】:

    • a、w 和 m 是什么意思?是否有 Java 版本,因为我得到了一些线条,但中间部分我不明白它在做什么?
    • Python 代码抛出了很多向量运算符,它们完全隐藏了循环。如果您正在寻找 Java 代码,那么在 nayuki.eigenstate.org/res/free-small-fft-in-multiple-languages/… 有一个 Bluestein 的 chirp-z 变换的 Java 实现;见方法transformBluestein
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多