I've got a few thousand scanned images that I am trying to crop. I'm writing a script that will crop the pictures accordingly if I can determine whether the source image is a 3x5 picture or a 4x6 picture from the uncropped border (scanner lid).
I've found command-line tools to compare and match entire images (using imagemagick convert), but not a designated region of an image:
convert img1.jpg "img2.jpg" -compose difference -composite -colorspace gray miff:- | identify -verbose - | sed -n '/^.*mean: */{s//scale=2;/;s/(.*)//;s/$/*100\/32768/;p;q;}' | bc
(it's usually a match if the result < .10, but it is cpu-intensive)
Is there a tool or Python image library that will let me match compare certain regions from two images to see if they match? The uncropped regions are not plain white, as evidenced by the example images below (1 3x5, 1 4x6). All I need to match is the first 100 or so pixels, and obviously I can't match the entire image. I have considered copying and cropping the image and matching the crop to a reference image, but that seems less than optimal.