Next: Using General Transforms Up: Transforms Previous: Linear Transforms

General Transforms

General transforms can represent linear transforms, non-linear (via thin-plate splines) transforms, user defined transforms, and concatenations of these. All functions dealing with general transforms involve objects of type General_transform.


public  void  create_linear_transform(
    General_transform   *transform,
    Transform           *linear_transform )

Creates a general transform consisting of a single linear transform, specified by linear_transform. If a NULL is passed as the argument linear_transform, then an identity transform is created.


public  void  create_thin_plate_transform(
    General_transform    *transform,
    int                  n_dimensions,
    int                  n_points,
    float                **points,
    float                **displacements )

Creates a general transform consisting of a thin plate spline, which provides a smooth non-linear mapping of a multidimensional space. The points argument is an array of size n_points by n_dimensions, representing a set of points. The displacements is a (n_points + n_dimensions + 1) by n_dimensions array, which is created by the following function:


public void  get_nonlinear_warp(
    float **transformed_points,
    float **original_points,
    float **displacements,
    int   n_points,
    int   n_dimensions )

Fills in the displacements array with the appropriate values to achieve a thin-plate spline transformation. The mapping will provide a smooth transformation of space such that each point in the original_points array maps exactly to the corresponding point in the transformed_points array. These displacements are then fed into the function create_thin_plane_transform to create the general transform.


typedef  void   (*User_transform_function)( void  *user_data,
                                            Real  x,
                                            Real  y,
                                            Real  z,
                                            Real  *x_trans,
                                            Real  *y_trans,
                                            Real  *z_trans );

public  void  create_user_transform(
    General_transform         *transform,
    void                      *user_data,
    size_t                    size_user_data,
    User_transform_function   transform_function,
    User_transform_function   inverse_transform_function )

Creates a user defined transformation, by copying the user data (size_user_data bytes of data starting at user_data). Two function pointers are also required, to specify the method of transforming points and inversely transforming points. These functions are of the type User_transform_function, which is specified above.


public  void  delete_general_transform(
    General_transform   *transform )

Frees up the memory stored in the general transform structure.


public  Transform_types  get_transform_type(
    General_transform   *transform )

Returns the general transform type, one of LINEAR, THIN_PLATE_SPLINE, USER_TRANSFORM, or CONCATENATED_TRANSFORM.


public  Transform  *get_linear_transform_ptr(
    General_transform   *transform )

If the general transform is of type LINEAR, then returns a pointer to the linear transform (of type Transform), for use with the routines specific to linear transforms, described earlier. Otherwise prints an error message.


public  void  concat_general_transforms(
    General_transform   *first,
    General_transform   *second,
    General_transform   *result )

Concatenates two general transforms. If both transforms are of type LINEAR, then the result is also of this type, being the matrix product of the two. Otherwise, the resulting transform is simply the concatenation of the two transforms.


public  int  get_n_concated_transforms(
    General_transform   *transform )

Returns the number of concatenated transforms in the given transform. If the type of the transform is CONCATENATED_TRANSFORM, then the number returned is the number of transforms, otherwise it is one.


public  General_transform  *get_nth_general_transform(
    General_transform   *transform,
    int                 n )

If the transform is of type CONCATENATED_TRANSFORM, then a pointer to the n'th transform is returned, where n is greater than or equal to zero and less than the number of transforms in the concatenated transform.



Next: Using General Transforms Up: Transforms Previous: Linear Transforms


david@pet.mni.mcgill.ca
Fri Feb 17 15:37:42 EST 1995