Lens Shading Correction

Lens Shading Correction

Lens shading is an imaging artifact where the corners or edges of an image are darker than the center. It is caused by the reduction of the amount of light received by the sensor at the periphery of the image due to the characteristics of the lens.

Lens shading can be corrected by using a calibrated image based on the optics and lighting used in the application. Lens shading correction then adjusts the intensity at different points of the image to achieve a more uniform brightness.

Once a calibration file has been created it can be deployed across multiple cameras. If there is a change in the imaging environment, a new calibration file can be created and redeployed.

Using Lens Shading Correction

Lens shading correction can only be enabled if there is a valid calibration file loaded on the camera. The calibration file can be created by the camera or loaded from an existing calibration file saved to a disk. The calibration file is saved across power cycles of the camera. There can be up to two calibration files saved to a camera.

Creating a Calibration File

To create a calibration file:

  1. Ensure the LensShadingCorrectionMode is set to OFF.
  2. Use the LensShadingCoefficientCurrentActiveSet to select where to save the file.
  3. Execute LensShadingCorrectionCalibrationSetup. This changes the camera’s settings as follows:
    • Maximum resolution
    • No binning or decimation
    • Auto gain enabled
    • Auto white balance enabled
    • 8-bit pixel format selected
    • Black level clamping enabled (if applicable)
    • Black level set to 0
  4. The camera is now in an ideal state to prepare a target scene:
    1. Ensure the scene is a uniform plain target without artifacts.
    2. Ensure an appropriate lens is attached to the camera.
    3. Start acquisition in the streaming window.
    4. Verify your scene has stabilized (for auto exposure and white balance) and check for any image artifacts.
    5. Stop acquisition.
  5. Execute LensShadingCorrectionCalibration. This begins the calibration process which takes ~10 seconds after which a file is saved to the selected Coefficient Active Set.
  6. The LensShadingCorrectionCalibrationStatus provides the status of the file:
    • Calibration Complete—the file was created successfully
    • Saturated—the file is brighter than expected; the average is 80% of the maximum pixel value
    • Low Region—one or more of the regions has no signal; one region's average creates full gain coefficient or has 0 average pixel value
    • Calibration Incomplete—no calibration file has been created with this camera yet, or the current calibration was stopped without a successful result
  7. After the file is saved, the Lens Shading Correction mode is automatically set to Active.
  8. Start acquisition.

In some cases, a high level of gain in the dark areas may cause a grid patterned image artifact. If this artifact is observed in your image, you can set the LensShadingCorrectionCalibrationGainLimit to a lower value and recreate the calibration file.

Downloading a Calibration File from a Camera

Once a valid calibration file has been created, you can download it to make available for other cameras.

  1. Open the SpinView application and from the Feature pane select the File Access tab.
  2. From the Camera File Access drop-down, select the file.
  3. Click Download and select a location to save the file.

Uploading a Calibration File to a Camera

If you want to use an existing calibration file created on a different camera you can load this using the File Access feature.

  1. Open the SpinView application and from the Feature pane select the File Access tab.
  2. From the Camera File Access drop-down, select where you want to save the file.
  3. Click Upload and select the file.
  4. Once the file is saved to the camera, Lens Shading can be enabled.

Enabling Lens Shading Correction on a Camera

Once a valid calibration file is present on the camera – either by creating or uploading – Lens Shading can be enabled.

  1. Use the LensShadingCoefficientCurrentActiveSet to select which file to use. Note: a valid calibration file must be present on the camera.
  2. Set the LensShadingCorrectionMode to Active.
  3. Start acquisition.

Summary Table

Name Interface Access Visibility Description
Lens Shading Correction Mode IEnumeration Expert Activates Lens Shading Correction with the selected Lens Shading Coefficient Active Set.
Lens Shading Coefficient Active Set IEnumeration Expert Facilitates selection of on camera shading correction calibration files.
Lens Shading Correction Step Size IInteger RO Expert The grid step size for the lens shading algorithm on the camera.
Lens Shading Correction Version IInteger RO Expert The version number of the lens shading algorithm on the camera.
Lens Shading Correction Calibration Gain Limit IInteger Guru Maximum gain value set for the lens shading algorithm on the camera.
Lens Shading Correction Calibration Setup ICommand WO Expert Set up the camera parameters needed to be set for shading correction calibration. At least one image must be acquired after the setup for proper calibration.
Lens Shading Correction Calibration ICommand WO Expert Performs the shading correction calibration on the last image transmitted to the host in memory.
Lens Shading Correction Calibration Status IStringReg Expert Returns the current status of the Calibration.

Lens Shading Correction Features


Lens Shading Correction Mode

Activates Lens Shading Correction with the selected Lens Shading Coefficient Active Set.

Property Value
Name LensShadingCorrectionMode
Interface IEnumeration
Access
Visibility Expert

Enumeration Values
Off
Active

Lens Shading Coefficient Active Set

Facilitates selection of on camera shading correction calibration files.

Property Value
Name LensShadingCoefficientActiveSet
Interface IEnumeration
Access
Visibility Expert

Enumeration Values
UserShadingCoeff1
UserShadingCoeff2

Lens Shading Correction Step Size

The grid step size for the lens shading algorithm on the camera.

Property Value
Name LensShadingCorrectionStepSize
Interface IInteger
Access RO
Unit
Visibility Expert

Lens Shading Correction Version

The version number of the lens shading algorithm on the camera.

Property Value
Name LensShadingCorrectionVersion
Interface IInteger
Access RO
Unit
Visibility Expert

Lens Shading Correction Calibration Gain Limit

Maximum gain value set for the lens shading algorithm on the camera.

Property Value
Name LensShadingCorrectionCalibrationGainLimit
Interface IInteger
Access
Unit
Visibility Guru

Lens Shading Correction Calibration Setup

Set up the camera parameters needed to be set for shading correction calibration. At least one image must be acquired after the setup for proper calibration.

Property Value
Name LensShadingCorrectionCalibrationSetup
Interface ICommand
Access WO
Visibility Expert

Lens Shading Correction Calibration

Performs the shading correction calibration on the last image transmitted to the host in memory.

Property Value
Name LensShadingCorrectionCalibration
Interface ICommand
Access WO
Visibility Expert

Lens Shading Correction Calibration Status

Returns the current status of the Calibration.

Property Value
Name LensShadingCorrectionCalibrationStatus
Interface IStringReg
Access
Visibility Expert