Java / JAI - save grayscale image

I am trying to keep tiff instead of color gray-scaled. How can i do this? (JAI should be used because it's tiff!)

Many thanks in advance and best regards.

+4
source share
2 answers

You want to download the JAI Image I / O Tools , which provides ImageIO adapters for JAI. Once you have installed this, it will be smooth.

final BufferedImage in = ImageIO.read(new File("frabozzle.tif")); final BufferedImage out = new BufferedImage( in.getWidth(), in.getHeight(), BufferedImage.TYPE_BYTE_GRAY); out.getGraphics().drawImage(in, 0, 0, null); ImageIO.write(out, "TIFF", new File("graybozzle.tif")); 
+3
source

Given BufferedImage , you can use the filter() method of ColorConvertOp , as shown in this example .

+3
source

Source: https://habr.com/ru/post/1300458/


All Articles