General Transforms

General transforms can represent linear transforms, thin-plate spline transforms, grid transforms, and 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 function get_nonlinear_warp(), which is not included in this library.

public  void  create_grid_transform(
    General_transform    *transform,
    Volume               displacement_volume )

Creates a general transform consisting of a grid transform, which provides a smooth non-linear mapping of a multidimensional space. The displacment_volume argument is a four dimensional volume representing the displacements for the x, y, and z directions. Three of the dimensions of the volume must correspond to the x, y, and z spatial dimensions, and the fourth must have exactly three components, the displacements in each direction in world space. The dimensions may be in any order.

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.