5
\$\begingroup\$

enter image description hereI have about 1,000 scanned / photographed images, each with different formats but all with rectangular/square shape, that need to be cropped to remove the background and the white space around the images. The cropping needs to be done in an intelligent way, for example by identifying the background (wooden table / brown color range) and white space around each photo, preferably rotated to vertical/horizontal position (max few degrees) and crop to a rectangular format.

I'd expect that, in these days of artificial intelligence with software that recognizes faces, there is a software app to do that but after several hours searching I haven't been able to find one. I have read multiple articles on this forum and elsewhere on the web and tried multiple options, but none of them do a proper job:

  • Photoshop automatic crop and straighten function (in batch action) fixes less than 10% of the images and continuously needs manual intervention. It also creates multiple cropped artefact images with tiny cropped areas and cannot figure out which one to save;
  • GIMP cropping (as described by Francois Malan) only works to separate out images from one scanned page, not for cropping many single images;
  • Irfanview cannot intelligently find the borders so is useless;
  • ImageMagic (and many other apps) that I have tried do not have this automatic capability either.

All these programs, including Photoshop, are great if you want to crop using fixed positions and/or formats, but none of these seem to have the intelligence to find the white edges of an image and use that for cropping. Cropping 1,000 images by hand (with Photoshop support) will take me probably about 30 hours work (2 minutes each including some deskewing).

Any suggestion? The key topics in stackexchange are several years old so perhaps there is a new app that can handle this without manual intervention. Given the potential time savings I don't mind paying for software that does a proper job. Worst case I will re-photograph all images spending about 10-15 seconds extra per image to make sure they are lined up horizontally and do the cropping while taking the photo (or send them to someone in a low-wage country to do this for me :-)). Cheers

\$\endgroup\$
5
  • 1
    \$\begingroup\$ Google does what you describe in their PhotoScan app, but they haven't released anything that works with preexisting image files. \$\endgroup\$
    – xiota
    Mar 23, 2019 at 15:46
  • 1
    \$\begingroup\$ Half the problem is that the photo isn't square or even flat in the shot. You're going to need something that can either 'smart perspective crop' or be taught to, in effect, under-scan to square them up. \$\endgroup\$
    – Tetsujin
    Mar 23, 2019 at 18:50
  • 1
    \$\begingroup\$ This exemplifies the importance of not just the camera rig in using a camera-as-scanner, but the necessity of using an easel as well so that images are flat and in the same exact spot. \$\endgroup\$
    – OnBreak.
    Mar 24, 2019 at 1:31
  • \$\begingroup\$ The PhotoScan approach is great. The app would be extremely useful if it had high pixel rate, proper correction, low distortion, and proper sharpening and contrast. Unfortunately, the present app has none of these and is only good for social media low resolution usage. I doubt if Google is interested to expand this smart app for more professional use... \$\endgroup\$
    – Gert
    Mar 25, 2019 at 10:12
  • \$\begingroup\$ Point taken to create a proper setup. A little extra time spent during the initial scanning saves a ton of work in after processing. Luckily I have the option to redo these images and straighten/crop them immediately. In my naivety I assumed that any decent image software, and for sure Photoshop, would have a tool to fix it. I had too high hopes of AI capabilities... \$\endgroup\$
    – Gert
    Mar 25, 2019 at 10:18

3 Answers 3

2
\$\begingroup\$

I made a free website (https://www.autocropper.io/) that automatically crops the individual photos from multi-photo scans. It works via Python OpenCV and specifically searches for rectangular shapes surrounded by white edges. Here's an example scan with 4 photos:

enter image description here

I tested your example image and it detected the image:

autoCropper.io with your example img

You can upload 10 scans at a time. If you have more example images with differing backgrounds, feel free to share and I can better understand your use case. It was originally built for digital scanned images instead of actual pictures.

No download required, it's an in-browser application. I wrote extensively on how my image detection algorithm works using Python OpenCV if you want to run it locally. See here https://www.autocropper.io/technical-overview

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for disclosing you made the tool. Very much appreciated! And welcome to Photo-SE. =) \$\endgroup\$
    – scottbb
    Feb 5 at 5:13
1
\$\begingroup\$

Middle-of-the-road solution with Gimp, that crops and straightens the images, assuming all your pictures are numbered in some directory (IMG_2027.JPG, IMG_2028.JPG, as long as there is an identifiable number suffix, you can even have missing numbers).

  1. install the ofn-file-next script, and use Edit>Keyboard shortcuts to assign it to a key.
  2. File>Open the first picture
  3. Start the Perspective tool and set it to Direction: Corrective and Clipping: Clip
  4. Click on the image, and drag the four corner handles to the four corners of your image
  5. Strike [Enter](the image is clipped/straightened)
  6. Strike the File>Next shortcut: the image is saved, and the next image in sequence is opened
  7. Repeat from step 4

After a few images, you can be as fast a 10-15 seconds/image...

\$\endgroup\$
2
  • 1
    \$\begingroup\$ For the straight pics you can use the crop tool. If you know the actual aspect ratio (3:2?), images can be batch-rescaled by a script in a following step, or you can pad the source images to the required aspect ratio (also by script) before you crop/straighten (slightly better quality). \$\endgroup\$
    – xenoid
    Mar 25, 2019 at 10:39
  • \$\begingroup\$ You're right. Solution is indeed to do a basic crop first followed by the Perspective tool, thereby adding time. Due to my lack of a standard setup all images are unique. Key learning is a) apparently there is not a smart tool to do that and b) a proper setup is key.. \$\endgroup\$
    – Gert
    Mar 25, 2019 at 10:41
0
\$\begingroup\$

I tested your scan using a Mac app, SnipTag. This app has 2 cropping engines: Both auto-cropped the image correctly but didn't rotate it to upright orientation. SnipTag (and its cousin, Snip) can batch crop scans i.e. you could submit dozens of scans at a time. Also, if you capture multiple photos per scan, they are cropped and saved individually. It helps if you scan in accordance with the guidelines included in the app.Scan cropped with the two engines, bottom right Both apps are free to try [Disclosure: I do customer service at AIL, developer of these apps.]

\$\endgroup\$
2
  • \$\begingroup\$ Yes, I do customer service. And sorry, in my enthusiasm to answer the question relevant to this app, I skipped the disclosure protocol. Just got chastised for this internally, too. Have edited the above response. \$\endgroup\$
    – MacEater
    Dec 7, 2020 at 4:15
  • \$\begingroup\$ Thanks for the update and disclosure. Much appreciated! =) \$\endgroup\$
    – scottbb
    Dec 7, 2020 at 5:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.