# Arguments of ShapeTransformer estimateTransformation method

Greetings,

I'm a computer programmer who is working on a personal image processing project using opencv. The goal is to implement an image warp function which allows you to pick a point on an image and drag it along with the image distorting to fit around it. From what I've been reading I got the idea that a thin plate spline transformation can be used to achieve this effect.

I have found the ThinPlateSpline ShapeTransformer class in the Opencv documentation but even after reading the algorithm description in various papers (I do not have a Maths background) I have difficulty in understanding the parameters required in the estimateTransformation method. I presume that the first one is a set of initial points and the second is a set of target points where the only change between the two will be the point which I will "drag" to a new position. Is this correct?

I cannot comprehend the third argument though, which contains a set of "matches". As I only have a single image (or point set) to work on, how can I compare it with a " second " inage to find common points so that I can then pass them on as an argument? All I know is the new coordinate of the point which I will move.I have looked at the algorithm again and while I get the gist of the vector maths and tracked the relevant lines of the source code that implement them I could not find a link between that and this requirement for a set of matches

Any help or pointers to sources that can clarify the way this works would be welcome.

Thanks!

edit retag close merge delete

Sort by ยป oldest newest most voted

The idea is that whatever method you are using to find the contours may not start and end at the same place, or may have additional or missing points. So it provides the matches vector to allow you to specify exactly which points match. In your case, it doesn't matter so much. Just create a vector of DMatch with the index set to the same number.

matches.push_back(DMatch(0,0,0));
matches.push_back(DMatch(1,1,0));
matches.push_back(DMatch(2,2,0));
matches.push_back(DMatch(3,3,0));
...

more

If I understand it correctly then, the DMatch array would have been more relevant if I had a second "target" image and I was trying to morph another ("source") image into it rather than the open-ended "drag and drop" scheme I am trying to implement?

( 2016-10-09 15:45:57 -0500 )edit

Exactly. In this case you have exactly the same number of points in the same order. Natural images that you're finding shapes in do not.

( 2016-10-09 16:00:38 -0500 )edit

Thanks for clarifying this for me!

( 2016-10-09 16:02:50 -0500 )edit

Official site

GitHub

Wiki

Documentation