Marco A.
Marco A.

Reputation: 43662

Getting the distortion transformation from points

Is it possible to get a rectangle distortion from few fixed points?

This example will explain better what I mean:

Suppose I've got this image with a rectangle and two points, the two points are recognized in the other image where the image is distorted

enter image description here

How can I reproduce the distortion knowing the position of the two(or maybe three) previous points??

My purpose is to get the distorted rectangle border. It's not an easy image as the one in the example so I can't just filter colors, I need to find a way to get the distorted image border.

Upvotes: 2

Views: 709

Answers (2)

mrgloom
mrgloom

Reputation: 21622

shift and rotation need - 2 points

Affine tranform need - 3 points

Perspective tranform need - 4 points

Upvotes: 0

peakxu
peakxu

Reputation: 6675

I believe what you're looking for can be described as an affine transform. If you want general transform of a planar surface, you may want perspective transform instead.

You can find the OpenCV implementation here. The relevant functions are cv::getAffineTransform which requires 3 pairs of points or cv::getPerspectiveTransform which requires 4 pairs of points.

Note: if you're using an automatic feature detector/matcher, it would be best to use far more point pairs than the minimum and use a robust outlier rejection algorithm like RANSAC.

Upvotes: 1

Related Questions