I have a square, low-resolution photo, which has been cropped (by the user) out of a high-resolution, non-square, original. The low-res photo has then been resized downwards into a thumbnail. I'd like to automatically (no user-intervention required) re-crop the original photo in the same way to achieve a higher-resolution copy of the square version. I do not have access to the original cropper coordinates. All I have are these two photos.
Here are some example images (from my Facebook profile) to illustrate what I mean:
Original, high-resolution photo - Cropped, then shrunk, square photo
Again, the goal is to use the small photo as a guide to get a much higher resolution square photo from the source.
The only constraints on the solution are:
Does anyone have any ideas? I don't know a lot about image processing, so I wouldn't really know where to start.
EDIT: For Facebook, specifically, there is a solution that is not nearly so hard. The original crop data is available for profile images: https://graph.facebook.com/bcherry/profile?fields=pic_crop
This is going to get me over my immediate hurdle, but may not be a long-term solution, so the answers provided below are still quite helpful to the more general problem.
While I will not comment to Javascript-ness of my solution - you're basically trying to perform Image Registration between the original and cropped, resized image.
There are many different methods to do something like this - for your particular purpose, I would start with a Phase-Correlation like approach.
EDIT: I just found a nice script using ImageMagick that does exactly what you need. NormCrossCorr "computes the normalized cross correlation surface to find where a small image best matches within a larger image."
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With