在Java中将位图图像转换为未压缩的tif图像
我正在尝试将位图图像转换为未压缩的 tif 文件,以便与 Tesseract OCR 引擎一起使用。
我可以使用此方法生成压缩的 tif 文件...
final BufferedImage bmp = ImageIO.read(new File("input.bmp"));
ImageIO.write(bmp, "jpg", new File("output.tif"));
当“jpg”更改为 tif 时,这会生成一个空的 tif 文件,因为这些文件是在 Java 高级成像 (JAI) 中处理的。
如何创建未压缩的 tif 图像?我应该解压缩由上述代码生成的 tif 图像还是有其他方法来处理转换过程?
任何提供的例子将不胜感激。
感谢
Kingh32
I'm trying to convert a bitmap image into an uncompressed tif file for use with the Tesseract OCR engine.
I can use this method to produce a compressed tif file...
final BufferedImage bmp = ImageIO.read(new File("input.bmp"));
ImageIO.write(bmp, "jpg", new File("output.tif"));
This produces an empty tif file when the "jpg" is changed to tif as these files are dealt with in Java Advanced Imaging (JAI).
How can I create an uncompressed tif image? Should I decompress the tif image produced from the above code or is there another way to handle the conversion process?
Any examples provided would be much appreciated.
Thanks
kingh32
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用
ImageWriteParam
禁用压缩:You can use
ImageWriteParam
to disable compression:之前一段时间,我遇到了使用 jai 读取和转换 tiff 图像的问题。
我发现它需要安装在 jai 中处理 tiff 图像的支持,那么它对我来说效果很好,你也可以在这里获取它:
https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef =jaiio-1.0_01-oth-JPR@CDS-CDS_Developer
并通过 jvm 安装,那么它也适用于您。
你也可以看看这里
Java / JAI - 将图像保存为灰度
Some time before i was facing the problems with tiff images reading and conversion with jai.
I found that it need to install support for working with tiff images in jai, then it works fine for me u can also get it form here:
https://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/ViewProductDetail-Start?ProductRef=jaiio-1.0_01-oth-JPR@CDS-CDS_Developer
and install over a jvm then it will also work for you.
you can also have a look here
Java / JAI - save an image gray-scaled