Crop and change perspective of image

14 views (last 30 days)
HaMo
HaMo on 8 Dec 2022
Edited: HaMo on 8 Dec 2022
Let's say I have a photograph of a rectangular painting. When the photograph was taken, the camera was tilted about the yaw, pitch and roll axes relative an axes that projects in a perpendicular direction out from the painting. Also, in the photograph the painting is framed by the wall behind the painting. I want to crop the image and change the perspective so that it appears that the painting was right in front of the camera, and without the wall behind it. Nevermind the distortions to the image.
In python, it can be done with a single command. The input is the coordinates of the painting's four corners in the photograph's coordinate system, and the output is the coordinates of all four corners of a rectangle (in an arbitrary cartesian coordinate system).
Is there a similar simple way to achieve this in Matlab ?

Accepted Answer

DGM
DGM on 8 Dec 2022
Edited: DGM on 8 Dec 2022
You can use fitgeotrans() and imwarp(). It's a little more generalized, so it's not exactly a one-liner.
Here is one example correcting the perspective of a photo of a whiteboard.

More Answers (0)

Products


Release

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!