f



Why can't we 'tformfwd' a cp2tform(..., 'polynomial')

Hi,

Just as an example:

This is allowed
    xybase = reshape(randn(12,1),6,2);
    t_affine = cp2tform(xybase,xybase,'affine');
    [x,y] = tformfwd(t_affine,xybase,xybase);

but this
    t_poly = cp2tform(xybase,xybase,'polynomial',2);
    [x,y] = tformfwd(t_poly,xybase,xybase);

gives an error

"Function TFORMFWD expected T's forward_fcn field to be non-
empty."

I checked the code a bit and indeed, with the 'polynomial' 
case, the
findPolynomialTransform() function has at its end

trans = maketform('custom',2,2,[],@inv_polynomial,[A B]);

where the fourth argument, the [], is where the  
'forward_fcn' function should go.

Is it a non-sense to ask to do this operation? But the 
imtransform() function accepts
the t_poly transform.

Thanks

J. Luis

0
Joaquim
9/5/2007 3:18:26 PM
comp.soft-sys.matlab 211266 articles. 16 followers. lunamoonmoon (258) is leader. Post Follow

2 Replies
716 Views

Similar Articles

[PageSpeed] 19

Joaquim Luis wrote:
> Hi,
> 
> Just as an example:
> 
> This is allowed
>     xybase = reshape(randn(12,1),6,2);
>     t_affine = cp2tform(xybase,xybase,'affine');
>     [x,y] = tformfwd(t_affine,xybase,xybase);
> 
> but this
>     t_poly = cp2tform(xybase,xybase,'polynomial',2);
>     [x,y] = tformfwd(t_poly,xybase,xybase);
> 
> gives an error
> 
> "Function TFORMFWD expected T's forward_fcn field to be non-
> empty."
> 
> I checked the code a bit and indeed, with the 'polynomial' 
> case, the
> findPolynomialTransform() function has at its end
> 
> trans = maketform('custom',2,2,[],@inv_polynomial,[A B]);
> 
> where the fourth argument, the [], is where the  
> 'forward_fcn' function should go.
> 
> Is it a non-sense to ask to do this operation? But the 
> imtransform() function accepts
> the t_poly transform.

imtransform uses inverse mapping, so it requires a spatial 
transformation in the inverse direction (output space to input space). 
Unlike an affine transform, a polynomial transform is not invertible, so 
you can't start from a polynomial transform defined in the inverse 
direction and compute the corresponding forward transform.

You can find a series of posts on spatial transformations between 
January and August 2006 on my blog.  See the archive page:

http://blogs.mathworks.com/com/archives/

These in particular might be of interest:

http://blogs.mathworks.com/steve/2006/04/28/spatial-transforms-forward-mapping/

http://blogs.mathworks.com/steve/2006/05/05/spatial-transformations-inverse-mapping/

http://blogs.mathworks.com/steve/2006/07/27/spatial-transformations-handling-noninvertible-cases/

-- 
Steve Eddins
http://blogs.mathworks.com/steve
0
steve.eddins (785)
9/5/2007 3:27:01 PM
Steve Eddins <Steve.Eddins@mathworks.com> wrote in message 
> imtransform uses inverse mapping, so it requires a 
spatial 
> transformation in the inverse direction (output space to 
input space). 
> Unlike an affine transform, a polynomial transform is 
not invertible, so 
> you can't start from a polynomial transform defined in 
the inverse 
> direction and compute the corresponding forward 
transform.
> 
> You can find a series of posts on spatial 
transformations between 
> January and August 2006 on my blog.  See the archive 
page:
> 
> http://blogs.mathworks.com/com/archives/
> 
> These in particular might be of interest:
> 
> http://blogs.mathworks.com/steve/2006/04/28/spatial-
transforms-forward-mapping/
> 
> http://blogs.mathworks.com/steve/2006/05/05/spatial-
transformations-inverse-mapping/
> 
> http://blogs.mathworks.com/steve/2006/07/27/spatial-
transformations-handling-noninvertible-cases/


Steve,
I'm a reader of your blogs and when you mentioned it I had 
a recall of the subject (a bit too late). 

Thanks

J. Luis
0
Joaquim
9/5/2007 4:21:43 PM
Reply: