Flat Field Correction / Shading Correction in VisualApplets

  • What is a flat field correction / shading correction?

    • Subtract fixed pattern noise from camera images (FPN correction)
    • Correct the photo response non uniformity PRNU of the sensor
    • Correct the shading inhomogeneity due to lens and lighting
    • An individual correction value is defined for every pixel of the sensor image.


    • I = incoming camera image
    • I* = output image
    • Offset = FPN correction value
    • Gain = PRNU or shading correction value


    The flat field correction uses fixed point arithmetic:

    • Calculation accuracy needs to be sufficientfor the project requirements
    • Fixed point correction values are used

    8 Bit camera example:


    --> we define 8 bit for offset and 8 bit for gain correction values à 2 Byte correction values are required for each sensor pixel

    12 Bit camera example:


    --> We define 16 Bit for offset and 16 Bit for gain correction values à 4 byte correction values required for each sensor pixel

    VisualApplets Implementation



    • The FFC implementation can be scaled to any desired performance
    • --> Use a sufficient parallelism. For example parallelism 32 on microEnable 5 frame grabbers will result in 2000MPixel/s
    • --> Use a fast DRAM to store the correction values.
      • See the target device resources to obtain the DRAM architecture of your frame grabber LINK
      • Parameterize the CoefficientBuffer to high speed implementations.
    • Example ironman: Input 2000MPixel/s, 2 Byte correction values/pixel à 4000MByte DRAM bandwidth requirement à 2 DRAMs

    Calculation of the Correction Values

    • The calculation of the correction values should be done on the host PC in a software application (C++, Matlab, Halcon, …)
    • For FPN correction values
      • Acquire a dark image i.e. cover the lens
      • Offset(x,y) = DarkImage(x,y)
    • For PRNU of shading correction values
      • Acquire a grayscale image. Pixel values should not be in saturation but as bright as possible.
      • Define a reference gray value white pixels are corrected to.
      • Gain(x,y) = ReferenceValue / (GrayImage(x,y) – DarkImage(x,y))
    • Use a Silicon Software AcquisitionApplets to record the RAW dark and gray camera images. See LINK


    The attached VisualApplets design “SimulationOnly_MakeFFCCoefficients.va “ is a simulation only design. It can be used to load the dark and gray images to calculate the offset and gain correction values which can be loaded into operator CoefficientBuffer for the FPGA implementation VisualApplets design “Shading2D_VCX-QP_highSpeed.va”. --> No software program to calculate the offset and gain is required if you use the VisualApplets simulation to get the correction values. Otherwise you can use any software like Matlab, Halcon, C++etc. to get the values.


    Next you can apply the generated correction values.



    The following to images show the camera image before and after FFC correction.



    The attached ZIP file contains VA Design files and simulation images.


    Johannes Trein
    Group Leader R&D
    frame grabber

    Basler AG