ImageMagick trimming to a border

ⅰ亾dé卋堺 提交于 2019-12-01 10:04:32

问题


I'm using ImageMagick to trim margins off of a scanned page.

The page has a black border and for our purposes looks something like this:

These are scans though, so there's often dust and other gunk making things less pretty. The command I'm using for the trimming is:

convert <filename> -crop \
  `convert <filename> -virtual-pixel edge -blur 0x15 -fuzz 40% -trim \
    -format '%wx%h%O' info:` +repage <filename>

This is mostly copied from various forums (I don't know what -format does, for instance). And it works well when the image has the black border and not much else outside it. Sometimes, however, the scans have things written in the margins or on top. I'd like to ignore everything outside the border but I don't quite know enough ImageMagick to tinker productively.

Any thoughts?


回答1:


I ended up using a combination of some ImageMagick with using this line segment detector with some tricky parameters to find the borders and crop to those.



来源:https://stackoverflow.com/questions/20149281/imagemagick-trimming-to-a-border

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!