public static Image makeBlackAndWhitePng(PdfImageObject image) throws IOException, DocumentException {
File f = new File("C:\\Users\\anahata\\Desktop\\text analysis\\14-1.png");
BufferedImage bi = image.getBufferedImage();
BufferedImage x = new BufferedImage(bi.getWidth(), bi.getHeight(), BufferedImage.TYPE_INT_ARGB);
x = ImageIO.read(f);
BufferedImage newBi = new BufferedImage(bi.getWidth(), bi.getHeight(), BufferedImage.TYPE_USHORT_GRAY);
newBi.getGraphics().drawImage(bi, 0, 0, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ImageIO.write(x, "png", baos);
return Image.getInstance(baos.toByteArray());
}