I have an image processing question.
Suppose I have this image as input:
And I also have the user's specifications of the boundaries of a rectangle:
And I want to get this image as output:
The flow I am imagining so far is:
- User uploads input image
- User specifies the boundaries of an object that is supposed to be a rectangle
- My app does a series of transformations to achieve the output image
A few considerations:
- The area provided by the user is not just a rectangle rotated. It will most often not be rectangular at all, especially if there's depth in the image, like in the example. This is fine, and the image will need to be distorted, so that the result IS a rectangle.
- I understand that by doing simple transformations I won't be able to correct depth, i.e. if in the input image there was one of the corners that was farther away from the camera (deeper) then I'm not hoping to correct that. All I want is to move the 4 corners to the correct positions they would have on a perfect horizontal rectangle, and then move all the other pixels in the image accordingly. I am ok with some distortion in the output image. At this point I'm at an exploratory phase with this, to see what it would look like.
In a nutshell, what I'm trying to do is:
Any ideas?
Can this be done with simple transformations? How? Is there a library that could help?
Btw the end result will be done in a web app, using web technologies.