一直找不到合适的工具,就想自己写个软件来做这件事情。设想用 xnview 的
addon-on SDK (filter plugin API),
但是似乎 xnview 内带的批处理不支持调用 addon-on 。可以脱离 xnview 主程序
直接调用 xnview 提供的 GFL SDK API 库 [2]
来做图像处理。
用 xnview 里面提供的 autocrop 可以达到实现部分效果。对于黑边,可以用
Image > automatic crop,设置 background color 为
黑色,测试一个合适的 tolerance 值,就可以部分去除黑边。参见附件 book
scan crop black border.ppt。
试验了一下 Imaging Express [4] ,去除黑边不完全,没有达到需求,但是其提
供的自动放正图片的功能 (deskew, straighten) 尚可,未研究是否支持批处理。
BordersHelper [3] 的介绍说只支持单色图像,看它的说明似乎基于 [6] 给出的
算法。但是下载网页失效了。
Recogniform [1] 是一个开发库,试验了一下基于同样技术的 Recogniform Image
Processor 5.0 [7],效果不错,批处理方式。
但试用版无法正常使用,会在输出图片上画一个大叉。购买价格太贵,约 900 欧。
Recogniform 支持 DLL 调用或者 ActiveX 调用,支持去黑边 black border
removal, 纠正歪斜 deskew, 去黑点 despeckle, 去表格线条 line removal,
动态阀值转换为黑白图像 dynamic thresholding 。意大利人做的,售价 600
欧。以下摘自 SDK 的 demo 说明文件 DemoReco.txt。 试验了 SDK 的
Evaluation download,需要密码,无法正常使用,只供演示。
------
Deskew
------
This function estimates the image inclination angle and correct it
using a very fast and accurate fine-rotation method.
You can select to estimate only or to estimate and correct the skew.
You have to supply the maximum angle to check, the angle resolution
and you can balance the speed/accuracy
Works on monochorme, grayscale and color images.
---------
Despeckle
---------
This function allows to remove noise points from the image.
You have to supply the max width and height of the isolate points
to be removed.
Works on monochorme images.
------------
Line Removal
------------
This function finds and remove horizontal and vertical lines.
You can choice to remove only horizontal or vertical lines or
both.
You can supply the minumum size for horizontal and vertical
lines as well as the maximum size of "holes" in lines.
As option you can choice to reconnect crossed character and to
clean lines border after remotion.
NOTE: To have best results you need to deskew the image before to
use this function.
Works on monochorme images.
------------
Thresholding
------------
This function allows to convert a 256 grayscale image in a monochrome
image.
You can choice the kind of algo to use.
Here you will find our "state of art" algorithms.
Works on color and grayscale images.
============================================
www. - in...@recogniform.com
============================================
Adobe CS3 Photoshop 据说有个 Crop and Straighten 功能可以切除黑边 [5]。
看了一下说明,是用于一次扫描多张照片,然后自动切割成单张照片的。
许多扫描文件处理软件甚至支持自动去除订书钉,打孔等阴影 [9][10][11],自动
倾斜纠正,背景去除,污点去除等等许多功能。论文 [6] 中有他提出的算法和其
他著名的商业软件的处理效果的对比。
找到一个 opensource 的软件,unpaper [12],这是最有希望作为改进的基础。它
支持单/双页版心(page mask, 也就是 bounding box)识别,页面边距 (border)
识别,大块阴影去除 (black filter),污点去除 (noise filter, blur
filter),背景去除 (gray filter), 版心扶正 (deskew),版心重定位居中
(border aligning) 等许多复杂的功能。先试验它的算法对我的需求是否有效。估
计可能其识别阴影的算法,对于我采用了短边距扫描之后的边缘阴影很窄的情形效
果不会太好。
opensource 软件 ImageMagick 支持 -fuzzy -trim [13],和 xnview 的 auto
crop 功能类似,可以用于切除宽度均匀的黑边。如果黑边是倾斜的,宽度不均
匀,就无法完全切除了。
opensource 软件包 NetPBM 10.35 版之后提供一个 pgmdeshadow 命令 [15],可
以对灰度图像的边缘渐变阴影进行亮度修正。这适合修正那些普通平板扫描仪,相
机拍摄的书本页面边缘的阴影,尤其当阴影中有需要保留的文字,不能简单切除的
时候。这一算法应该加入 unpaper 。[6] 的算法有公开的论文,也可以加入
unpaper。我想把我设想的算法也加进去。参见附件 book scan crop black
border.ppt。
目前可以采用的图像处理的库,opensource 的有 ImageMagick /
GraphicsMagick, NetPBM, GD [17]。xnview 的 GFL SDK 是 freeware 但是非
opensource,次优选择。
如果采用 ImageMagick,可以直接处理 TIFF, JPG, PNG 等图像文件格式,而
NetPBM 则需要转换为 pbm, pgm, ppm, pam 等中间格式,如果不用管道数据交换
方式,就要用硬盘文件。为加快速度,可以采用内存虚拟盘 Ramdisk 保存临时文件。