有人知道如何在 Java 中使用 BoofCV 的小波变换(Haar 或 Daubechies)吗?
网络上没有代码示例,我对这个库很陌生。
我在下面尝试了这段代码,但没有结果。
public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException {
String dir = "C:\\Users\\user\\Desktop\\ImgTest\\";
BufferedImage buff =UtilImageIO.loadImage(dir+"img.png");
ImageUInt16 aux = UtilImageIO.loadImage(dir+"img.png", ImageUInt16.class);
ImageSInt16 input = new ImageSInt16(aux.width, aux.height);
input =ConvertImage.convert(aux, input);
ImageSInt32 output = new ImageSInt32(aux.width, aux.height);
int minPixelValue = 0;
int maxPixelValue = 255;
WaveletTransform<ImageSInt16, ImageSInt32, WlCoef_I32> transform =
FactoryWaveletTransform.create_I(FactoryWaveletHaar.generate(true, 0), 1,
minPixelValue, maxPixelValue,ImageSInt16.class);
output=transform.transform(input, output);
//BufferedImage out = ConvertBufferedImage.convertTo(output, null);
BufferedImage out = new BufferedImage(input.width*6, input.height*6, 5);
out = VisualizeBinaryData.renderLabeled(output, 0, out);
ImageIO.write(out, "PNG", new File(dir+"out.png"));
}
}
我也尝试过 JWave,但也没有代码示例,负责人也无法提供帮助。
谢谢!