cp2tform / tformfwd - are points outside controlpoints correctly transformed ?

3 views (last 30 days)
Emmanuel on 2 May 2012
I am getting erratic results when trying to transform a set of 2D points using cp2tform and tformfwd.
When the points to be transformed are situated outside the perimeter of controlpoints, I sometime get negative coordinates (ok knowing the position of my CP), but sometimes the transformed coordinates seem to default to (0,y) or (0,0).
I thought this was caused by the piecewise linear transformation I'm using (as matlab probably cannot draw triangles beyond CP limits), bu it seems I get the same behavior when using projective or polynomial transformations, and tformfwd or tforminv.
What surprises me the most is that I do not get any error or warning message when these outlier points are being (wrongly) transformed ...
Any ideas ?

Accepted Answer

Emmanuel on 22 May 2012
An update about the original question, after more torough tests:
- the problem I got initially was caused by my own code, sorry about that.
- however, If this can help anybody, I discovered that piecewise linear TFORM behaves strangely if control points describe a non-convex polygon, creating triangles with zero area in the output space. These triangles are transformed to a segment that seem to "attract" even points outside the cp polygon. I don't have the skills to test it properly, but this may suggest that piecewise linear transform might be unreliable in some cases, e.g. for processing images with barrel distorsion.

More Answers (2)

Sean de Wolski
Sean de Wolski on 2 May 2012
How colinear are your control points? If the points are relatively colinear then the contraints in the perpendicular dimension will not be good.

Emmanuel on 2 May 2012
Thank you Sean,
I have 8 CP describing a rectangle in real coordinates:
X = 0 40 80 0 80 0 40 80 Y = 0 0 0 60 60 120 120 120
Is that too colinear ? should I remove some CP ? These are really all the CP I can have...
Is there a transformation type that would handle points outside this rectangle correctly ?

Community Treasure Hunt

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

Start Hunting!

Translated by