Functions | |
I32 | lens_transform (image *src, image *dst, point *center, F32 k3, U8 bgnd) |
Lens Distortion Correction (Subpixel Interpolated). More... | |
I32 | lens_transform2 (image *src, image *dst, point *center, F32 f, F32 magnification, U8 bgnd) |
Lens Distortion Correction Using Tilted Camera Assumption. More... | |
void | deinit_lens_transform2 () |
Deallocates 2D Table for Lens Transform. More... | |
I32 | init_lens_transform2 (F32 f, F32 magnification, I32 nr, I32 nc) |
Allocates and Initializes a Table for General Lens Transforms. More... | |
The function performs a lens correction transformation.
Pincushion- and barrel-type distortions can be corrected. Distortions of this type typically increase with the square of the distance to the optical centerpoint. The transformation is performed using the following formula:
Pixels for which the corresponding source image is not defined, are set to bgnd
.
src | Pointer to Source Image. |
dst | Pointer to Destination Image. |
center | Centerpoint for Transform. |
k3 | Transform Coefficient with
|
bgnd | Background Grey Value. |
ERR_NONE | on Success. |
I32 lens_transform2 | ( | image * | src, |
image * | dst, | ||
point * | center, | ||
float | f, | ||
float | magnification, | ||
U8 | bgnd | ||
) |
The function performs a subpixel interpolated lens correction for barrel-type distortions (subpixel interpolated radial lens correction according to Pers, Kovacic, Nonparametric, Model-Based Radial).
The function corrects non-linear circular symmetric distortions based on a universal model of the lens. The model assumes that the lens maps a part of a sphere to the CCD-sensor. All the user needs to know is the focal length of the lens in units of the sensor pixel size. The model cannot be applied to telecentric lenses and some specially corrected lenses and has to be approved for a specific lens. Also, it is possible that focal length parameter for this routine deviates from the actual f-value. The transformation is performed using the following formula:
The key parameter for the correction is f
, namely the focal length of the lens divided by the pixel size. For example, using a lens with a focal length of 6 mm together with a VC4472 camera ( 4.4×4.4µm pixel size) would be: . The factor of 1000 is due to the fact that 1 mm equals 1000 µm. The image can be magnified (
mag
> 1.0) or demagnified (mag
< 1.0). A tilt in the object plane (object plane not perpendicular to optical axis) can be easily adjusted by setting the transformation centerpoint (center.x
, center.y
) to some pixel outside the CCD midpoint, since this effectively rotates the optical axis. Pixels for which the corresponding source image is not defined, are set to bgnd
. When called the first time, the function builds up a table for the correction values. The memory for the table is automatically allocated and the table is calculated, which may take some time. The table is kept in memory for further use with the same parameters. If the parameters are changed, the old table will be released and a new table will be set up. To deallocate the table memory, the function void deinit_lens_transform2() should be called.
src | Points to Source Image. |
dst | Points to Destination Image. |
center | Centerpoint for Transform. |
f | Focal_Length_Of_Lens / Pixel_Size. |
bgnd | Background Grey Value. |
ERR_TYPE | if src and dst Type are not equal, or not valid. |
ERR_MEMORY | if Memory Allocation fails. |
ERR_NONE | on Success. |
ERR_TYPE | if src and dst Type are not equal, or not valid. |
ERR_MEMORY | if Memory Allocation fails. |
ERR_NONE | on Success. |
This function allocates and initializes a table for doing general lens transforms. If no change in parameters occured, there will not be any allocation or calculation. To deallocate the table, call the function deinit_lens_transform2().
ERR_MEMORY | if Memory Allocation fails. |
ERR_NONE | on Success. |
ERR_MEMORY | if Memory Allocation fails. |
ERR_NONE | on Success. |
ERR_MEMORY | if Memory Allocation fails. |
ERR_NONE | on Success. |
void deinit_lens_transform2 | ( | ) |
This function deallocates the 2D Table being allocated after calling init_lens_transform2().