This interface provide functionalities of flat field calibration and correction.
More...
|
LPVImageFormat | ColorMode [get, set] |
| The mode of the flat field tool, either handling grayscale or color image.
|
|
LColor | FromColor [get, set] |
| The raw sourcing color before flat field correction, for color mode.
|
|
int | FromGray [get, set] |
| The raw sourcing grayscale value before flat field correction, for grayscale mode.
|
|
int | KernelWidth [get, set] |
| The kernel size, it affects the updating range of the foreground and flat field during training and the smoothness of the result flat field. It should be an odd number, say, 3, 5, 7, etc. By default, it's 121.
|
|
LColor | ToColor [get, set] |
| The expected targeting color after flat field correction, for color mode.
|
|
int | ToGray [get, set] |
| The expected targeting grayscale value after flat field correction, for grayscale mode.
|
|
int | Tolerance [get, set] |
| The tolerance range of the color or grayscale value in image, in 1 ~ 50. By default, it's 10. 0 is the special value to make use of the entire image as foreground. It helps to build the color range of the foreground object of interest.
|
|
double | UpdateRate [get, set] |
| The learning rate to control how the flat field image is updated, in 0 ~ 1. The larger value means the higher weights in updating for the new input image. It is recommended to use a higher updating rate in the first some iterations, then lower it in the laters. By default, it's 0, indicates the update rate is calculated on the fly based on the ratio of known foreground pixels.
|
|
This interface provide functionalities of flat field calibration and correction.
Flat field correction is used to compensate for the non-uniformity characteristics of the camera and lens combination such as:
- the inhomogeneous illumination intensities in the field-of-view
- the differences of light sensitivity between the pixels on the camera sensor
- the shading of lens, which is a generic form of lens vignetting, where light falloff can be asymmetrical and can have a color cast
The standard way to do flat field calibration is with a uniform target covering the whole field-of-view, usually a gray or white card. You may then obtain the flat field image:
- Place the target to cover the whole view
- Adjust the lens aperture and the illumination intensity to obtain the brightest possible image providing that no pixels are saturated.
- Acquire several frames and blend them into one denoised image then pass it to the LFlatField object for training.
Another optional way is to use the target object in the actual inspection. The advantage of this method is that the real light reflection on the target object's surface is collected, making the correction more suitable for the material. To obtain the flat field image:
- Adjust the lens aperture and the illumination intensity to obtain the brightest possible image providing that no pixels are saturated and the inspected components are clear.
- Configure LFlatField for the raw and expected color or grayscale value, to extract the foreground pixels. You may alternatively adopt other locating tools to detect then generate the foreground regions or masks.
- Place then capture the image of the target on any possible location in the view, make sure the whole view is almost covered. Pass those images (and their foreground regions or masks) to LFlatField for training
To use this interface, you should create a LFlatField object.
Example Code
C++
Code snippets: snippets/FlatFieldWhiteBoard.cpp, snippets/FlatFieldSolar.cpp
ILFlatFieldPtr ffc = LFlatField::Create();
ffc->ColorMode = LPVImageFormat::LPVImageFormatGrayscale8;
ffc->ToGray = 160;
ffc->Tolerance = 0;
if (err != LPVErrorCode::LPVNoError) return;
err = ffc->Train(wbImg, NULL);
if (err != LPVErrorCode::LPVNoError) return;
ILImagePtr correctedImg = LImage::Create();
err = ffc->FixImage(rawImg, correctedImg);
if (err != LPVErrorCode::LPVNoError) return;
LPVErrorCode
This enumeration represents the type of a LPV function error.
Definition: LPVCore.idl:530
C#
Code snippets: snippets/FlatFieldWhiteBoard.cs, snippets/FlatFieldSolar.cs
LFlatField ffc = new LFlatField();
ffc.ToGray = 160;
ffc.Tolerance = 0;
err = ffc.Train(wbImg, null);
LImage correctedImg = new LImage();
err = ffc.FixImage(rawImg, correctedImg);
LPVImageFormat
This enumeration represents the format of the image.
Definition: LPVCore.idl:1640
COM
ILFlatFieldPtr ffc = LFlatField::Create();
ffc->ColorMode = LPVImageFormat::LPVImageFormatGrayscale8;
ffc->ToGray = 160;
ffc->Tolerance = 0;
if (err != LPVErrorCode::LPVNoError) return;
err = ffc->Train(wbImg, NULL);
if (err != LPVErrorCode::LPVNoError) return;
ILImagePtr correctedImg = LImage::Create();
err = ffc->FixImage(rawImg, correctedImg);
if (err != LPVErrorCode::LPVNoError) return;