[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Detect and crop borders of scanned image from command line



On Mon, Oct 25, 2004 at 09:02:56PM -0400, William Ballard wrote:
> How can I detect and crop this border from the command line?

Wrote my own thing using the Imagemagick C api.

Load image using MagickReadImage, get 100x100 blocks of pixels
using MagickGetImagePixels as "Intensity" values 0-255, look
for rows and cols which are all "dark" (Intensity < 4), crop
there.

Then for each 100x100 block on all four sides, get 10x10 blocks.
Working outside in orthogonally, if block is dark, overwrite with white 
pixels.  If block is not dark, stop.

Save file.  Pretty simple code.

Was there already a tool out there that did something like this?



Reply to: