VCLib Documentation  6.12.2

Shading Correction

Shading Correction

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...
 

Detailed Description

Function Documentation

◆ shading_correct_2D_mul()

I32 shading_correct_2D_mul ( image src,
image dst,
image mul 
)

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:

\[ px_{\texttt{dst}} = px_{\texttt{src}} * \frac{px_{\texttt{mul}}}{256}. \]

The minimum dimensions of all images will be processed.

Parameters
srcSource Image (Grey Image).
dstDestination Image (Grey Image), may be identical with src.
mulMultiplication Factor Image of Type IMAGE_GREY16.
Memory Consumption
None.
Return values
ERR_TYPEif Input or Output Image is not a Grey Image, or Multiplicator Image is not of Type IMAGE_GREY16.
ERR_NONEon Success.

◆ shading_correct_2D_mul_calib()

I32 shading_correct_2D_mul_calib ( image src,
image mul,
U32  u32AvgSizePx 
)

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:

\[ px_{\texttt{mul}} = \frac{256 * \textrm{mean}(\texttt{src}_{avg})}{px_{\texttt{src}_{avg}}}. \]

Parameters
srcSource Image (Grey Image).
mulMultiplication Factor Image of Type IMAGE_GREY16.
u32AvgSizePxSmoothing Parameter for Noise Reduction.
Return values
ERR_TYPEif src Image is not a Grey Image, or mul Image is not of Type IMAGE_GREY16.
ERR_SINGULARif src Image has a Grey Value of 255 or 0.
ERR_MEMORYif Image Allocation Fails.
boxavg()Error Code.
ERR_NONEon Success.

◆ shading_correct_1D()

I32 shading_correct_1D ( image src,
image dst,
I8 offs,
U16 mul 
)

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.

Note
This function was named shading_correct() previously.
Parameters
srcSource Image (Grey Image).
dstDestination Image (Grey Image).
offsLine Offset Buffer.
mulLine Shading Buffer.
Memory Consumption
None.
Return values
ERR_TYPEif Input or Output Image is not a Grey Image.
ERR_NONEon Success.

◆ shading_correct_1D_calib()

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.

Parameters
src1Source Image 1 (Grey Image).
src2Source Image 2 (Grey Image).
t1Shutter Value for image 1.
t2Shutter Value for image 2.
offsLine Offset Table (Output).
shadeShading Table (Output).
Note
This function was named line_calibrate() previously.
Memory Consumption
None.
Return values
ERR_TYPEif src1 or src2 is not Grey Image.
ERR_MEMORYif Memory Allocation Fails.
ERR_NONEon Success.

◆ line_IIR()

I32 line_IIR ( image src,
image dst,
I32  tol,
I32  int_const,
I32  p_const,
I32  target 
)

This function performs a recursive filter used in linescan applications.

Parameters
srcSource Image (Grey Image).
dstDestination Image (Grey Image).
tolGrey Value Tolerance for Averaging.
int_constIntegration Parameter.
p_constProportional Parameter.
targetTarget 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.

Return values
ERR_TYPEif Input or Output Image is not a Grey Image.
ERR_NONEon Success.