Scanning Large Amounts of Pictures?
ClintJCL asks: "My wife & I are involved in scanning every photo I've ever taken in my life. She can lay down 4 or 5 pictures into the flatbed scanner at once, thereby saving the scanning time which is the bottleneck. But then she has to split them with Photoshop, which is also somewhat time-consuming. I've searched on the net for hours for a piece of software that would automatically split these 'Batch image scans' into single images and it just doesn't seem to exist. There are plenty of pieces of software to split a single image arbitrarily into sections for the purpose of loading faster on an HTML page (which I disagree with anyway and is not what I'm looking for). But -nothing- that seems to do any sort of edge-detection to determine what pictures exist in a given 'scan batch'. I'm out of resources. I've nowhere else to go. Perhaps someone can clue me in on a piece of software that can do this for me."
Finding the image edges from her bulk scans is one of the more trivial operations you can do on an image. Grab a handy-dandy image library for your chosen format (pnglib, jpeg, whatever) and write a couple pages of code and you're done. GPL it and help others with the same problem.
11*43+456^2
- The border around every image shows a high contrast against the scanner background (which is usually white). This shouldn't be too much of a problem, unless you take lots of pictures of very light things.
- Your photographs are rectangular. This may sound silly, but it's a lot easier to find a rectangle than some arbitrary n-gon.
- Your photographs are placed so that edges of the photograph run parallel to the bed (i.e. you put the pictures down squarely)
If (1), (2) and (3) hold, then implementing this shouldn't be too bad --- I would use this algorithm:- take a scan of the background of the scanner (i.e. hit the scan button with no pictures on the bed) and remember this background image
- for each image in the input set
- perform edge detection
- use a Hough transform to detect lines in the edge map
- calculate the difference image D. If B[k](i,j) is the value of the k color band at pixel (i,j) in the background image and F[k](i,j) is the value of the k color band at pixel (i,j), then D(i,j) = max(abs(F[r](i,j)-B[r](i,j)),abs(F[g](i,j)-B[g](i
, j)),abs(F[b](i,j)-B[b](i,j))
- divide the difference image and the input image into rectangular regions using the lines that were detected with the Hough transform. For each region, calculate the average difference; if this value is large enough (i.e. over ~ 8-16), then consider that region to be a picture, otherwise it's blank space.
Intel's OpenCV library (look it up at SourceForge) can do most of the "tough" stuff for you (i.e. the edge detection and the Hough Transform). Hope this helps