autodetection of portrait-images

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
bablokb
Posts: 29
Joined: 2005-06-11T06:21:59-07:00

autodetection of portrait-images

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: autodetection of portrait-images

Post 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
Post Reply