Functions | |
I32 | shading_correct_2D_mul (image *src, image *dst, image *mul) |
Perform Multiplicative Shading Correction for an Image (Normal Non-Linescan Type). More... | |
I32 | shading_correct_2D_mul_calib (image *src, image *mul, U32 u32AvgSizePx) |
Gets Shading Correction Values from a Homogeneous Image. More... | |
I32 | shading_correct_1D (image *src, image *dst, I8 *offs, U16 *mul) |
Perform 1D Shading Correction for an Image (Linescan Type). More... | |
I32 | shading_correct_1D_calib (image *src1, image *src2, F32 t1, F32 t2, I8 *offs, U16 *shade) |
Calibrate the Shading Correction for an Image (Linescan Type). More... | |
I32 | line_IIR (image *src, image *dst, I32 tol, I32 int_const, I32 p_const, I32 target) |
Perform Line IIR Regulation of Background Intesity (Linescan Type). More... | |
This function calculates the multiplicative shading correction for image src
and outputs the result in image dst
. The shading correction algorithm consist of a multiplication with the line shading buffer mul
. The values in the shading buffer must be 256 for the identity operation. Larger values will result in an amplification, smaller values will result in a de-amplification. The formula is:
The minimum dimensions of all images will be processed.
src | Source Image (Grey Image). |
dst | Destination Image (Grey Image), may be identical with src . |
mul | Multiplication Factor Image of Type IMAGE_GREY16. |
ERR_TYPE | if Input or Output Image is not a Grey Image, or Multiplicator Image is not of Type IMAGE_GREY16. |
ERR_NONE | on Success. |
This function gets the values for the product image used for correcting multiplicative shading, like vignetting. After smoothing the source image over the given square pixel size, its mean value will be calculated. Then the values will be calculated according to the following formula:
src | Source Image (Grey Image). |
mul | Multiplication Factor Image of Type IMAGE_GREY16. |
u32AvgSizePx | Smoothing Parameter for Noise Reduction. |
ERR_TYPE | if src Image is not a Grey Image, or mul Image is not of Type IMAGE_GREY16. |
ERR_SINGULAR | if src Image has a Grey Value of 255 or 0. |
ERR_MEMORY | if Image Allocation Fails. |
boxavg() | Error Code. |
ERR_NONE | on Success. |
This function calculates the shading correction for image src
and outputs the result in image dst
. The shading correction algorithm consist in a subtraction of the offset values stored in the line offset buffer offs
and a multiplication with the line shading buffer mul
. The offset values may be positive (offset will be subtracted) and negative (offset wil be added). The values in the shading table must be 256 for the identity operation. Larger values will result in an amplification, smaller values will result in a de-amplification.
The size of both images must be identical. The size of the buffers must be dx = src->dx.
src | Source Image (Grey Image). |
dst | Destination Image (Grey Image). |
offs | Line Offset Buffer. |
mul | Line Shading Buffer. |
ERR_TYPE | if Input or Output Image is not a Grey Image. |
ERR_NONE | on Success. |
I32 shading_correct_1D_calib | ( | image * | src1, |
image * | src2, | ||
float | t1, | ||
float | t2, | ||
I8 * | offs, | ||
U16 * | shade | ||
) |
This function performs the line calibration necessary for the shading correction. Images src1
and src2
must be images of e.g. a plain white surface taken at different shutter speeds t1
(for src1
) and t2
(for src2
). The function the calculates the offset and shading tables.
Care must be taken that the source images are not overexposed and have grey values in a reasonable range. If the camera features positive pixel offset, it is possible to have one image taken at a very short exposure time with very low grey values. In this case this image would mainly be responsible for the calculation of the offset table offs, while the other image would mainly be responsible for the shading gain table shade. It is clear that there must be some difference in shutter time (hence in grey values), otherwise the algorithm will not produce stable results.
The routine performs a vertical projection on both of the input images. The images are then compared and the offset and shading tables are calculated so that for the maximum contrast value the multiplication (shade
) will be 256 (which is aquivalent to a multiplication with 1.0).
The size of both images must be identical. The size of the buffers must be dx = src->dx.
src1 | Source Image 1 (Grey Image). |
src2 | Source Image 2 (Grey Image). |
t1 | Shutter Value for image 1. |
t2 | Shutter Value for image 2. |
offs | Line Offset Table (Output). |
shade | Shading Table (Output). |
ERR_TYPE | if src1 or src2 is not Grey Image. |
ERR_MEMORY | if Memory Allocation Fails. |
ERR_NONE | on Success. |
This function performs a recursive filter used in linescan applications.
src | Source Image (Grey Image). |
dst | Destination Image (Grey Image). |
tol | Grey Value Tolerance for Averaging. |
int_const | Integration Parameter. |
p_const | Proportional Parameter. |
target | Target Grey Value. |
The algorithm may be used for surface inspection, where a homogeneous surface is inspected. It is mainly a regulation (tracking) of the grey values in a line. Assume, that the grey values in a line are in the same range within a tolerance (after the shading correction). Pixels not within this tolerance (tol
) are not considered. All the pixels within the tolerance are subtracted from the tracking average and the difference is integrated. The difference itself (proportional regulation) and the integrated difference (integration regulation) are multiplied with the corresponding constant int_const/1024
and p_const/1024
and used to produce a new tracking average. This average is then subtracted for the complete line, the target value target
is added to produce a destination image with an average value of target
.
The size of both images must be identical. The size of the buffers must be dx = src->dx.
ERR_TYPE | if Input or Output Image is not a Grey Image. |
ERR_NONE | on Success. |