Stray Light (Flare) Documentation

Stray Light Masking

Current Documentation
View previous documentation
View legacy documentation
All documentation versions


Stray light (flare) documentation pages

Introduction: Intro to stray light testing and normalized stray lightOutputs from Imatest stray light analysis | History

Background: Examples of stray lightRoot Causes | Test overview | Test factors | Test ConsiderationsGlossary

Calculations: Metric image | Normalization methodsLight source mask methods | Summary Metrics | Analysis Channels | Saturation

Instructions: High-level Imatest analysis instructions (Master and IT) | Computing normalized stray light with Imatest | Motorized Gimbal instructions

Settings: Settings list and INI keys/values | Standards and Recommendations | Configuration file input

Page Contents

This page provides a description of Imatest’s light source Mask Methods.

Masking (shorthand for “light source masking”) is the process of creating a mask to exclude the direct image of the light source from the analysis. The direct image of the source is the small region in the image that represents the true size of the light source (i.e., if there were no stray light or blooming in the image). The direct image of the light source is not stray light, which is why it should be masked (ignored) in a stray light metric image. 

Mask Methods

The Imatest stray light source analysis has several options or methods available for masking the light source in the image(s). Different mask options have different inputs allowing the user to configure the masking process and accuracy.

Note: If using the Reference Image normalization method, separate mask options are available for the test images and the reference image. 

Image Processing

Description

This method uses image processing-based methods to mask out the light source in the image. 

Inputs

    • Level Threshold Type: The type of threshold used for localizing the light source in the image.
    • Level Threshold (Value or Percent): The threshold above which is considered the image of the light source, as either a value (digital number) or a percentage of the maximum value in the image.
    • Minimum Source Level: The minimum image value (digital number) that can be considered a direct image of the light source. This is used to prevent masking stray light when the source is out of the FOV. 
    • Mask Area Threshold: The minimum number of pixels that the direct image of the light source should be (minimum area in pixels for the mask). This setting is meant to prevent noise or other small bright artifacts from being detected as potential mask regions. 
    • Image Close RadiusThis setting is only accessible in the INI. The radius of an image close morphology step during Image Processing. This helps to remove holes in the mask. Set to 0 to skip this step. 
    • Multiple CC StrategyThis setting is only accessible in the INI. The strategy for how to deal with multiple connected components when computing the mask.  
    • The minimum pixel count threshold

Calculation

Calculation Overview

    1. Compute the level threshold for the image or use the entered Level Threshold (Value)
    2. Check that the level threshold for the image is greater than the entered Minimum Source Level. If less, the source is assumed to be outside the FOV and no mask is generated for the image. 
    3. Create an initial mask by finding all of the pixels greater than the level threshold
    4. (Optional) Perform an image-closing morphology with a disk of the user-specified size (Image Close Radius). This helps to fill in small holes within the mask
    5. Compute the number of connected components in the mask
      • If zero connected components are found, then the light source is assumed to be out of the FOV
    6. Filter out any connected components that have an area smaller than the user-provided Mask Area Threshold
      • If zero connected components remain, then the light source is assumed to be out of the FOV
    7. Apply the strategy for selecting from one or more connected-component (Multiple CC Strategy)

Level threshold calculation

If the Level Threshold Type is Percent of Max:

    1. Calculate the maximum value in the image
    2. The threshold is the user-provided percentage (Level Threshold (Percent)) of this value

If the Level Threshold Type is Value:

    1. Use the user-provided threshold (Level Threshold (Value))

If the Level Threshold Type is Otsu’s method

    1. Use Otsu’s method to calculate a threshold from the image

Multiple Connected Component Strategies

If there is only one connected component:

    • This is assumed to be the light source.
    • A mask of just this connected component is returned

If there are no connected components:

    • The light source is assumed to be outside the field of view.
    • A mask with no light source(s) is returned

If the user-provided multiple-connected component strategy (Multiple CC Strategy) is “Don’t mask”:

    • A mask with no light source(s) is returned

If the user-provided multiple-connected component strategy (Multiple CC Strategy) is “Pick Biggest”:

    • The largest of the remaining connected components is assumed to be the light source
    • A mask of the largest connected component is returned

Assumptions

    • There is only a single light source in the image

Notes

    • The Image Processing method may not provide accurate localization of the direct image of the source if the level light source is above saturation and significantly blooming. The Image Processing + Circle (Radius) method is recommended in the case where the light source is saturated and significantly blooming. 

Recommendations

    • Level Threshold (Value) 
      • Pick the largest value (digital number) that the direct image of the source is always greater than in the image. 
    • Level Threshold (Percent)
      • If the direct image of the source is completely saturated, set it to 100%
      • If the Mask Method is Image Processing, then the goal of the Level Threshold is to mask only the direct image of the source. Using a value between 95% and 100% will work well in most cases (a hot pixel being an exception)
      • If the Mask Method is Image Processing + Circle (radius), then the goal of the Level Threshold is to get a good estimate of the center of the direct image of the source, so that a circle of a specified radius can be drawn there. Using a value between 90% and 95% will work well in many cases
      • If following IEEE-P2020 Pre-Release, set to 95%. Note that this may not work well for images that exhibit saturation and/or blooming. 
    • Minimum Source Level
      • When configuring Test Image Mask Options, pick a value between the dimmest value (digital number) of the direct image of the source when it is in the FOV and the brightest stray light value in the image when the source is outside the FOV.
      • When configuring Reference Image Mask Options, set the value to 0 (the source should always be in the reference image)
      • Note: This setting is only useful if the level threshold type is Percent of Max or Otsu’s Method

    • Mask Area Threshold
      • Use the default. Larger values will cause larger masses detected by the Level Threshold to be ignored. 
    • Image Close Radius (INI Only: image_close_radius)
      • Use the default. Larger values will fill in bigger holes in the mask.
    • Multiple CC Strategy (INI only: multiple_cc_strategy)
      • Use the default.

Image Processing + Circle (Radius)

Description

The Image Processing + Circle radius method uses two “steps” to determine the masked region. In the first step, the light source is localized via Image Processing methods. In the second step, a circle of a specified radius is placed at the center of the localized region and is used as the mask for the image. This method can avoid over-masking in the presence of large areas of saturation.

Inputs

    • Step 1
    • Step 2
      • Mask Radius: The radius (in pixels) to use for a circle (placed at the centroid of the region found in Step 1) that would represent the direct image of the light source

Calculation

    1. Apply the “first step” (Image Processing) to the image to determine a mask region
      1. If no mask region is found, the light source is assumed to be out of the FOV
      2. If a mask region is found, the light source is assumed to be in the FOV
    2. Compute the centroid of the mask region
    3. Apply the “second step” by creating a circle of specified radius at the found centroid to use as the final light source mask

Assumptions

    • There is only a single light source in the image
    • This method assumes relatively low distortion
      • The light source size is constant over the images
      • The image of the light source is always a circle

Notes

    • This method does not perform well if the light source is partially in and partially out of the FOV.
    • The centroid is assumed to be relatively stable in the presence of noise or saturation.
    • The centroid may be a non-integer (sub-pixel) value. Therefore the number of masked pixels is not constant.
    • The first step is currently always an Image Processing mask method.

None

Description

Do not mask out the source.

Inputs

N/A

Calculation

N/A

Assumptions

N/A

Notes

Warnings

  • When the image of the light source is partially out of the FOV, the assumptions used to generate a mask may be violated.
    • This may lead to improperly defined masks.
    • It is recommended that all light source masks are checked.
  • When the image of the light source is entirely out of the FOV, the assumptions used to generate a mask may be violated.
    • This may lead to improperly defined masks.
    • It is recommended that all light source masks are checked.

Generic Notes

  • Mask creation channel
    • If the analysis channel is Luminance or RGB + Luminance, then the luminance channel is used to create the mask.
    • Otherwise, the mean of all provided channels is used to create the mask.
  • Mask application channel
    • For each capture position, the same mask is applied to each of the analysis channels.