Given an image of a table with photographs (take from any angle), I'm trying to extract the photographs and correctly align them into perfect rectangles. There are four steps to the algorithm:
Detect quadrangles in the input image
Filter out non-photograph quadrangles
Re-project the quadrangles to a bird's-eye view
Correct for curved edges in the sub-images
Here's an example of doing the first two steps:
- For each of detected photographic quadrangles an orange outline is drawn.
- I've added a green one to emphasize the fidelity of solution I'm looking for, we can't lose any pixels in this process.
- Notice how the orange rectangles do not contain any white margins - we just want them to shrink-wrap the photographic content.
Ok, then here's what the remaining steps look like:
Note that for each of reprojected photograph (shown on the left) we fix the warping/curvature of the photograph by transforming it into a perfectly rectangular image (on the right).
Here's an example image to try:
Import @ CloudObject[
"https://www.wolframcloud.com/objects/d3999fcf-7a01-4d60-bb9c-38604d252475"]
And as requested, some additional examples to test with:
CloudGet @ CloudObject["https://www.wolframcloud.com/objects/068cf32f-b753-4c38-bc01-f378bc64d54a"]
ImagePerspectiveTransformation
. $\endgroup$ImagePerspectiveTransformation
will help to re-project the image but we would have to assume a fixed aspect (the most common print aspects are 5x7, 4x6, 8x10). But deriving correct segmentations in step 1 and 2 is the hardest part IMO $\endgroup$