1

I am looking to write an algorithm to cut rectangular images and straighten them in a new image. The bigger concept is that I will be scanning a bunch of physical pictures (on a physical scanner). They're all the same size (give or take a couple of pixels) and I can make sure they're all separated, so they're absolutely not overlapping or touching each other.

As a result of this, I want to split them up into separate files, so I can easily digitize a load of pictures, whose physical copies belonged to my grandmother and now have to be divided among different families.

Does any algorithm exist for this scenario, or am I forced to think up my own? I was thinking about simply trying to find the corners of the images first, then cutting the squares out using these corners, then simply rotating them. There might be an easier/faster processing time way though (or an existing product!)

  • Can you post "illustration" what kind of photos you are getting? From what you are saying, it seems simple edge detection would do. But you would still need to program it. – Euphoric Jul 13 '15 at 6:16
  • Family pictures. Which might well have a lot of white pixels on the sides. They're all rectangular though, and pretty much "standard" pictures. I'm of course willing to also manually cut out a couple where it goes wrong (i.e. the ones where corner detection goes wacky due to white pixels), as long as 95% do go right. – Kristof Jul 13 '15 at 6:22
  • Potential answer to the question you did not ask: yes, there is a way to scan lots of photos much faster than with a flatbed scanner. If you are looking for an interesting side project, then by all means. But if you need to scan lot of photos quickly, I recommend a scanner that feeds in the photos. Recently digitized several thousand and it was definitely worth the chunk of change. However, if you must use the flatbed then perhaps take a look here for a GIMP plugin that does this sort of thing. – J Trana Jul 14 '15 at 4:16
  • Well it seems there is an imagemagick plugin that does what I need. Which scanner did you get exactly then? – Kristof Jul 14 '15 at 5:09
0

What you are trying to do is typically a series of image processing problems. Have a look at algorithms in ImageJ such as the canny edge detector for finding edges in an image. This will produce a greyscale image where edges are lighter in color than non edges. These can sometimes do the job of finding the edge well enough with a little contextual help on your part. Then by choosing some intensity threshold, you can get only the edges from the image and use that slice the image up. Also consider filtering the images by their RGB values before running the edge detector on them.

  • 1
    Given that you're doing the scanning, I would also highly recommend that you optimize the input dataset by adding a sheet of vividly colored flat paper behind the whole set of photographs. Green or blue is a traditional color for this, but you should pick something that isn't prevalent In the photographs. After you do so, you'll want to run your edge and corner detectors on a copy of the image filtered by that color, which should make them all pop nicely. – Chris Subagio Jul 13 '15 at 20:10
  • Agreed. Hight contrast outside the images is your friend in detecting the edges. – Jason K. Jul 13 '15 at 21:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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