我使用的是来自this问题的Java fftw3包装器。 (代码here)
我只想将第二种类型的DCT变换应用于双元素数组,但如果我尝试调用fftw_execute
方法,我会不断收到此错误:
java(787,0x10b243000) malloc: *** error for object 0x7fba642c5408: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
为什么?
这是我的代码:
package com.project.fftw3;
import java.io.File;
import java.io.IOException;
import java.nio.DoubleBuffer;
import fftw3.FFTW3Library;
import fftw3.FFTW3Library.fftw_plan;
public class MainClass {
static FFTW3Library fftw = FFTW3Library.INSTANCE;
public static void main(String[] args) {
int i,j,w,h;
File in = new File("Images/Baboon.bmp");
//File out = new File("Baboon-" + System.currentTimeMillis() + ".txt");
try {
ImageMatrix im = new ImageMatrix(in);
w=im.getImageWidth();
h=im.getImageHeight();
double [] row = im.getRow(0);
double [] oarr = new double[w];
DoubleBuffer din = DoubleBuffer.wrap(row);
DoubleBuffer dout = DoubleBuffer.wrap(oarr);
fftw_plan p = fftw.fftw_plan_dft_1d(din.array().length,din,dout,5,FFTW3Library.FFTW_ESTIMATE); //5 is REDFT10
fftw.fftw_execute(p);
fftw.fftw_destroy_plan(p);
} catch (IOException e) {
}
}
}
答案 0 :(得分:0)
看起来你的尺寸错误了:
double [] oarr = new double[h];
将其更改为:
double [] oarr = new double[w];
这与您看到的错误一致,假设w>小时。