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... | |
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.
src | Pointer to the source image. |
tbl | Pointer to the table image (type = IMAGE_CMPLX16). |
dst | Pointer to the destination image. |
bgnd | Background grey value. |
ERR_FORMAT | if src or dst is NULL. |
ERR_TYPE | if src is not of type IMAGE_GREY. |
ERR_TYPE | if dst is not of type IMAGE_GREY. |
ERR_TYPE | if tbl is not of type IMAGE_CMPLX16. |
ERR_FORMAT | if size of dst and tbl are different. |
ERR_NONE | on Success. |
ERR_FORMAT | if src or dst is NULL. |
ERR_TYPE | if src is not of type IMAGE_GREY. |
ERR_TYPE | if dst is not of type IMAGE_GREY. |
ERR_TYPE | if tbl is not of type IMAGE_CMPLX16. |
ERR_FORMAT | if size of dst and tbl are different. |
ERR_NONE | on Success. |
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.
tbl | Pointer to the table image (type = IMAGE_CMPLX16). |
dx | Horizontal size of the source image used for the transform. |
dy | Vertical size of the source image used for the transform. |
ERR_TYPE | if tbl is not of type IMAGE_CMPLX16. |
0 | if no correction has been made. |
1 | if correction on left boundary necessary. |
2 | if correction on right boundary necessary. |
4 | if correction on top boundary necessary. |
8 | if correction on bottom boundary necessary. |
ERR_TYPE | if tbl is not of type IMAGE_CMPLX16. |
0 | if no correction has been made. |
1 | if correction on left boundary necessary. |
2 | if correction on right boundary necessary. |
4 | if correction on top boundary necessary. |
8 | if correction on bottom boundary necessary. |