java image library_Java image library to deskew and crop images

可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):

问题:

Does anybody have a suggestion for a java library that performs automatic cropping and deskewing of images (like those retrieved from a flatbed scanner)?

回答1:

ImageMagick can do that; you can use the ImageMagick Java bindings. The auto-crop operator is probably what you're looking for. Automatic deskewing is a much harder problem and involves some significant image processing; I'm not sure if ImageMagick can handle that. If you can figure out the skewing parameters using something else, ImageMagick can definitely unskew it for you.

回答2:

I wrote a not that simple port of a very good deskewer. It works best if you have some text in the image.

回答3:

I'd imagine that someone has built a library on top of the Java Advanced Imaging API for doing this. You could try Googling for "Java Advanced Imaging deskew".

回答4:

I've written a simple image deskew app, includes source. Available at:

回答5:

Deskewing

There is an example on how to use it on the test folder of the tess4j project Tesseract1Test.java public void testDoOCR_SkewedImage() throws Exception { logger.info("doOCR on a skewed PNG image"); File imageFile = new File(this.testResourcesDataPath, "eurotext_deskew.png"); BufferedImage bi = ImageIO.read(imageFile); ImageDeskew id = new ImageDeskew(bi); double imageSkewAngle = id.getSkewAngle(); // determine skew angle if ((imageSkewAngle > MINIMUM_DESKEW_THRESHOLD || imageSkewAngle < -(MINIMUM_DESKEW_THRESHOLD))) { bi = ImageHelper.rotateImage(bi, -imageSkewAngle); // deskew image } String expResult = "The (quick) [brown] {fox} jumps!\nOver the $43,456.78 #90 dog"; String result = instance.doOCR(bi); logger.info(result); assertEquals(expResult, result.substring(0, expResult.length())); }

7cc0205d480e7e93c55e84a03d7ec314.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值