[magick-users] -deskew with autocrop

Anthony Thyssen A.Thyssen at griffith.edu.au
Sun Mar 29 22:01:09 PDT 2009


On Sat, 28 Mar 2009 15:50:23 -0700
duc.sequere.aut.de.via.decede at imagemagick.org wrote:

| > convert -set 'option:deskew:auto-crop 10' scan9.pnm scan92.pnm
| 
| Notice the option:deskew.  This means it only works with the -deskew option.
| Also don't use the quotes.  We'll fix the documentation.
| 
| Programmically we auto crop by running a median filter across the image
| to eliminate salt-n-pepper noise.  Next we get the image bounds of the
| median filter image with a fuzz factor (e.g. -fuzz 5%).  Finally we
| crop the original image by the bounds.  The code looks like this:
| 
|   median_image=MedianFilterImage(image,0.0,exception);
|   geometry=GetImageBoundingBox(median_image,exception);
|   print("  Auto-crop geometry: %lux%lu%+ld%+ld",geometry.width,geometry.height,
|     geometry.x,geometry.y);
|   crop_image=CropImage(rotate_image,&geometry,exception);

A similar method to 'Trimming 'Noisy' Images' I developed to have trim
ignore small marks and concentrate on the more complex parts of an image.

Trimming 'Noisy' Images
   http://www.imagemagick.org/Usage/crop/#trim_blur


  Anthony Thyssen ( System Programmer )    <A.Thyssen at griffith.edu.au>
 -----------------------------------------------------------------------------
      With some difficulity and a complete lack of experience,
      Death was trying to wink.         --  Terry Pratchet, "Mort"
 -----------------------------------------------------------------------------
     Anthony's Home is his Castle     http://www.cit.gu.edu.au/~anthony/


More information about the Magick-users mailing list