Page 1 of 1

autodetection of portrait-images

Posted: 2009-02-24T03:39:15-07:00
by bablokb
Hello,

my scanner supports scanning slides in landscape and portrait-mode. My idea is to do a quick preview-scan in landscape-mode, use some magic IM-command-sequence to find out if the image really is landscape or not and then scan the slide with the correct orientation.

If the image is in portrait-orientation but scanned as landscape, I will have an image where the left-quarter and the right-quarter of the image are black (the slide is 36x24mm, but the scan only captures the center of the portrait-mode slide which is 24x36mm). So the idea is to extract these two regions, do some noise-removal and compare against a pure black image. If the difference is low, than it should be a portrait-image. If it is high, it is in landscape orientation.

What is the most efficient way to do that?

Thanks, Bernhard

Re: autodetection of portrait-images

Posted: 2009-02-24T11:03:05-07:00
by fmw42
why not just scan the whole slide and then remove the background using -fuzz and -trim

see http://www.imagemagick.org/Usage/crop/#trim

I also have two scripts that might help, autotrim and unrotate.

See http://www.fmwconcepts.com/imagemagick/index.html