The Flat-Field Correction (FFC) camera feature allows you to remove non-uniformities in the image caused by differing light sensitivities of the sensor pixels and by illumination and illumination optics.
Non-uniformities in images are a common occurrence in digital imaging. These are caused by variations in the brightness output of sensor pixels as well as by the influence of light source and illuminations optics. Flat-field correction minimizes these non-uniformities by correcting the original pixel values, thus improving image quality and subsequent analysis.
Before flat-field correction can be applied, the camera needs to be calibrated. This involves calculating appropriate correction data. With this, the original pixels can be corrected during image acquisition resulting in an improved image.
The implementation of the Flat-Field Correction feature varies depending on the type of flat-field correction used. Basler boost V cameras support block-based and column-based flat-field correction.
Block-based flat-field correction corrects image artifacts caused by photo response non-uniformities (PRNU) and low frequency variations deriving from the illumination and illumination optics. Block-based FFC "divides" the sensor into square blocks consisting of a certain number of pixels. During calibration, correction data is calculated for each square block, which is then interpolated and applied to each pixel of the sensor.
Column-based flat-field correction corrects image artifacts caused by dark signal non-uniformities (DSNU) and photo response non-uniformities (PRNU). For each column of the sensor, a correction value for both DSNU and PRNU must be calculated during calibration. During image acquisition, these column-wise correction values are applied to the original pixel values.
The following drawing shows the different principles of block-based and column-based flat-field correction.
Block-based flat-field correction: A sequence of bright field (flat field) images is taken to detect photo response non-uniformities (PRNU) and low frequency artifacts caused by, e.g., lighting or optics. The correction values (CV) are calculated by the camera and saved to the camera's flash memory.
Column-based flat-field correction: A sequence of dark field images is taken (A) to detect dark signal non-uniformities (DSNU) (dark current noise) and a sequence of bright field (flat field) images is taken (B) to detect photo response non-uniformities (PRNU). The correction values (CV) must then be calculated by the user and saved to the camera's flash memory.
The image artifacts are removed, provided that the flat-field correction feature is enabled. The original pixel values (OV) are corrected resulting in an improved image (Resulting Values, RV).
This step involves calibrating the camera and storing the calculated correction values in a file referred to as a flat-field correction set. You can create up to 16 correction sets.
You need the following item before you start creating a flat-field correction set:
A target with a uniform background, e.g., a white sheet of paper
Info
For best results, adjust the optics, frame rate, exposure time, gain, and camera temperature as you would for normal operation. Basler recommends acquiring the bright field images in your actual application environment.
To create a flat-field correction set:
Set the Width and Height parameters of the image ROI to their maximum values.
Illuminate the sensor homogeneously to 70 % saturation, e.g., by placing a white sheet of paper in the camera's entire field of view.
Set the BslFlatFieldCorrectionSelector parameter to BlockBased.
Set the BslFlatFieldCorrectionMode parameter to On.
Set the BslFlatFieldCorrectionSetIndex parameter to the desired index number of the set to be created, e.g., 2.
Click the Continuous Shot button in the toolbar of the pylon Viewer to start image acquisition.
Execute the BslFlatFieldCorrectionSetCreate command to create a new flat-field correction set. A sequence of bright images is acquired and evaluated. The resulting correction data are generated and collected in the flat-field correction set selected.
Save the settings to the camera's flash memory by executing the BslFlatFieldCorrectionSetSave command. If the flat-field correction set with, e.g., index number 2, already contains correction data, these are overwritten and replaced by the new correction values.
The created flat-field correction set is enabled automatically.
For best results, acquire the dark and bright field images in your actual application environment. Be aware that only static effects can be corrected. If you change, e.g., the lens or lighting, you must repeat this procedure.
To calculate the correction values:
Protect the sensor from light, e.g., by placing a plastic cap on the lens, and acquire a sequence of dark images.
Sum up the gray values of all pixels in all acquired images and divide the sum by the total number of pixels. The result is the mean gray value of all pixels in the dark field image (DMean).
Calculate the mean gray value for each column x (D(x)).
Illuminate the sensor homogeneously to 70 % saturation, e.g., by placing a white sheet of paper in the camera's entire field of view, and acquire a sequence of bright images.
Sum up the gray values of all pixels in all acquired images and divide the sum by the total number of pixels. The result is the mean gray value of all pixels in the bright field image (GMean).
Calculate the mean gray value for each column x (G(x)).
If necessary, determine a global dark offset value according to your needs (UserGD_Offset).
For each column x, calculate the coefficients DSNU_Coeff(x) and PRNU_Coeff(x) as follows:
Use the calculated values for setting the corresponding camera parameters via the pylon API.
Column index (x):BslFlatFieldCorrectionCoeffX
DMean:BslFlatFieldCorrectionDMean
DSNU_Coeff(x):BslFlatFieldCorrectionCoeffDSNU
PRNU_Coeff(x):BslFlatFieldCorrectionCoeffPRNU
UserGD_Offset:BslFlatFieldCorrectionUserGD
After having set all correction values for all columns, you can test flat-field correction by acquiring a series of images.
If you're satisfied with the image quality, save the settings to the camera's flash memory by executing the BslFlatFieldCorrectionSaveToFlash command.
// Set the type of flat-field correction to Block-Basedcamera.BslFlatFieldCorrectionSelector.SetValue(BslFlatFieldCorrectionSelector_BlockBased);// Set the flat-field correction mode to Oncamera.BslFlatFieldCorrectionMode.SetValue(BslFlatFieldCorrectionMode_On);// Set the desired index number of the set to be createdcamera.BslFlatFieldCorrectionSetIndex.SetValue(BslFlatFieldCorrectionSetIndex_1);// Create new flat-field correction data for the flat-field correction set selectedcamera.BslFlatFieldCorrectionSetCreate.Execute();// Save the correction data to the camera's flash memorycamera.BslFlatFieldCorrectionSetSave.Execute();
INodeMap&nodemap=camera.GetNodeMap();// Set the type of flat-field correction to Block-BasedCEnumParameter(nodemap,"BslFlatFieldCorrectionSelector").SetValue("BlockBased");// Set the flat-field correction mode to OnCEnumParameter(nodemap,"BslFlatFieldCorrectionMode").SetValue("On");// Set the desired index number of the set to be createdCEnumParameter(nodemap,"BslFlatFieldCorrectionSetIndex").SetValue("");// Create new flat-field correction data for the flat-field correction set selectedCCommandParameter(nodemap,"BslFlatFieldCorrectionSetCreate").Execute();// Save the correction data to the camera's flash memoryCCommandParameter(nodemap,"BslFlatFieldCorrectionSetSave").Execute();
// Set the type of flat-field correction to Block-Basedcamera.Parameters[PLCamera.BslFlatFieldCorrectionSelector].SetValue(PLCamera.BslFlatFieldCorrectionSelector.BlockBased);// Set the flat-field correction mode to Oncamera.Parameters[PLCamera.BslFlatFieldCorrectionMode].SetValue(PLCamera.BslFlatFieldCorrectionMode.On);// Set the desired index number of the set to be createdcamera.Parameters[PLCamera.BslFlatFieldCorrectionSetIndex].SetValue(PLCamera.BslFlatFieldCorrectionSetIndex.);// Create new flat-field correction data for the flat-field correction set selectedcamera.Parameters[PLCamera.BslFlatFieldCorrectionSetCreate].Execute();// Save the correction data to the camera's flash memorycamera.Parameters[PLCamera.BslFlatFieldCorrectionSetSave].Execute();
/* Macro to check for errors */#define CHECK(errc) if (GENAPI_E_OK != errc) printErrorAndExit(errc)GENAPIC_RESULTerrRes=GENAPI_E_OK;/* Return value of pylon methods *//* Set the type of flat-field correction to Block-Based */errRes=PylonDeviceFeatureFromString(hdev,"BslFlatFieldCorrectionSelector","BlockBased");CHECK(errRes);/* Set the flat-field correction mode to On */errRes=PylonDeviceFeatureFromString(hdev,"BslFlatFieldCorrectionMode","On");CHECK(errRes);/* Set the desired index number of the set to be created */errRes=PylonDeviceFeatureFromString(hdev,"BslFlatFieldCorrectionSetIndex","");CHECK(errRes);/* Create new flat-field correction data for the flat-field correction set selected */errRes=PylonDeviceExecuteCommandFeature(hdev,"BslFlatFieldCorrectionSetCreate");CHECK(errRes);/* Save the correction data to the camera's flash memory */errRes=PylonDeviceExecuteCommandFeature(hdev,"BslFlatFieldCorrectionSetSave");CHECK(errRes);
# Set the type of flat-field correction to Block-Basedcamera.BslFlatFieldCorrectionSelector.Value="BlockBased"# Set the flat-field correction mode to Oncamera.BslFlatFieldCorrectionMode.Value="On"# Set the desired index number of the set to be createdcamera.BslFlatFieldCorrectionSetIndex.Value=""# Create new flat-field correction data for the flat-field correction set selectedcamera.BslFlatFieldCorrectionSetCreate.Execute()# Save the correction data to the camera's flash memorycamera.BslFlatFieldCorrectionSetSave.Execute()
// Example: Set all correction values for all columns// Dark signal non-uniformity (DSNU) coefficient// CalculatedDSNU[0..width-1]// Photo response non-uniformity (PRNU) coefficient// CalculatedPRNU[0..width-1]for(x=0;++x;x<width){camera.BslFlatFieldCorrectionCoeffX.SetValue(x);camera.BslFlatFieldCorrectionCoeffDSNU.SetValue(CalculatedDSNU[x]);camera.BslFlatFieldCorrectionCoeffPRNU.SetValue(CalculatedPRNU[x]);}// Set the global dark offset valuecamera.BslFlatFieldCorrectionUserGD.SetValue(40)// Save the settings to the camera's flash memorycamera.BslFlatFieldCorrectionSaveToFlash.Execute();// Set the type of flat-field correction to Column-Basedcamera.BslFlatFieldCorrectionSelector.SetValue(BslFlatFieldCorrectionSelector_ColumnBased);// Set the flat-field correction modecamera.BslFlatFieldCorrectionMode.SetValue(BslFlatFieldCorrectionMode_On);
This sample code is only available in C++ language.