我可以使用来自java.awt.image.BufferedImage
的BufferedImage
对象与ImageJ类实例吗?例如,我可以使用BufferedImage
对象代替ImagePlus
对象吗?
我可以使用来自java.awt.image.BufferedImage
的BufferedImage
对象与ImageJ类实例吗?例如,我可以使用BufferedImage
对象代替ImagePlus
对象吗?
public static void processImage(InputStream inputFile, String outputFilePath, double scaleFactor, int interpolationMethod, double sigmaFactor) {
try {
BufferedImage bi = ImageIO.read(inputFile);
ImageProcessor ip = new ColorProcessor(bi);
ip.blurGaussian(sigmaFactor / scaleFactor);
ip.setInterpolationMethod(interpolationMethod);
ImageProcessor outputProcessor = ip.resize((int) (ip.getWidth() * scaleFactor), (int) (ip.getHeight() * scaleFactor));
IJ.saveAs(new ImagePlus("", outputProcessor), outputFilePath.substring(outputFilePath.lastIndexOf('.') + 1), outputFilePath);
} catch (Exception e) {
System.out.println("Error al comrpimir la imagen: "+e);
}
}
getBufferedImage()
方法(我通常更喜欢这种方式)。很高兴你解决了问题。 :) - Andrew Thompson