VCLib Documentation  6.12.2

Table Transformation (Undistortion)

Table Transformation (Undistortion)
I32 table_image_transform (image *src, image *tbl, image *dst, U8 bgnd)
 Subpixel Interpolated (Inverse) Table Map Image Transformation. More...
 
I32 check_transform_table (image *tbl, I32 dx, I32 dy)
 Check if Transform Table contains valid addresses and correct if necessary. More...
 

Detailed Description

Function Documentation

◆ table_image_transform()

I32 table_image_transform ( image src,
image tbl,
image dst,
U8  bgnd 
)

This function performs a general table-mapped geometric image transformation on the source image and outputs the result to the destination image. The function uses bilinear interpolation.

The transformation is definded by the table image tbl which must be of type IMAGE_CMPLX16. The first element of the complex pixel value defines x-position of the destination pixel in the source image, the second element defines the y-position. Both positions have the numerical format U12.4 with a 4-bit mantissa for the interpolation.

CAUTION: The function does not check if the x- and y-positions are all within the source image. This is to the responsibility of the user. It is a good idea to set all positions outside the source image to the maximum or minimum x- or y-position. In case of doubt, call function check_transform_table() first.

The resulting image always has the dimensions of the destination image. Missing areas are set to bgnd. Please be aware, that the function requires the inverse transformation table. It is not possible to use the function in-place, i.e. source and destination images must not overlap.

Parameters
srcPointer to the source image.
tblPointer to the table image (type = IMAGE_CMPLX16).
dstPointer to the destination image.
bgndBackground grey value.
Memory Consumption
None.
See also
affine_image_transform(), homography_image_transform().
check_transform_table().
Return values
ERR_FORMATif src or dst is NULL.
ERR_TYPEif src is not of type IMAGE_GREY.
ERR_TYPEif dst is not of type IMAGE_GREY.
ERR_TYPEif tbl is not of type IMAGE_CMPLX16.
ERR_FORMATif size of dst and tbl are different.
ERR_NONEon Success.
ERR_FORMATif src or dst is NULL.
ERR_TYPEif src is not of type IMAGE_GREY.
ERR_TYPEif dst is not of type IMAGE_GREY.
ERR_TYPEif tbl is not of type IMAGE_CMPLX16.
ERR_FORMATif size of dst and tbl are different.
ERR_NONEon Success.

◆ check_transform_table()

I32 check_transform_table ( image tbl,
I32  dx,
I32  dy 
)

This is a helper function for function table_image_transform(). Since it is necessary that the table used contains only valid source pixel addresses, function check_transform_table() can be used to make sure that this is the case. The function returns a status output if such a case has been found and automatically corrects the table addresses.

CAUTION: this function irreversibly changes the contents of the table tbl if necessary: For the correction the table values will be set to the closest border pixel in the source image. E.g. if the y-coordinate in the table is larger than dy-1, the value will automatically be set to dy-1.

The transformation is defined by the table image tbl which must be of type IMAGE_CMPLX16. The first element of the complex pixel value defines x-position of the destination pixel in the source image, the second element defines the y-position. Both positions have the numerical format U12.4 with a 4-bit mantissa for the interpolation.

The function returns 0 if the operation was successful and no changes have been made to the table. A negative error code can be returned in case of failure. If a correction in the table was necessary, the function returns a positive code indicating at which boundary of the source image the correction has been made. It is possible that more than one boundary condition has been detected, so be prepared that the function can return any combination of the boundary detection bits.

Parameters
tblPointer to the table image (type = IMAGE_CMPLX16).
dxHorizontal size of the source image used for the transform.
dyVertical size of the source image used for the transform.
Memory Consumption
None.
See also
check_transform_table().
Return values
ERR_TYPEif tbl is not of type IMAGE_CMPLX16.
0if no correction has been made.
1if correction on left boundary necessary.
2if correction on right boundary necessary.
4if correction on top boundary necessary.
8if correction on bottom boundary necessary.
ERR_TYPEif tbl is not of type IMAGE_CMPLX16.
0if no correction has been made.
1if correction on left boundary necessary.
2if correction on right boundary necessary.
4if correction on top boundary necessary.
8if correction on bottom boundary necessary.