Blemish Detect  detects visible sensor defects (typically blurred spots caused by dust in front of the image sensor). To ensure that visible blemishes are flagged— and blemishes below the threshold of visibility are not— the image is filtered by a response function derived from the Human Visual System (HVS). Filter settings are adjustable for a wide range of applications and viewing conditions. The IT version of Blemish Detect, which can be incorporated into automated testing systems, can significantly improve sensor yields.

For best results, Blemish parameters must be chosen with care.
Be sure to read the instructions!

The Blemish module was introduced in Imatest 3.6, January 2010 (Master-only)
Blemish Detect uses the same uniform featureless image as Light Falloff, but its emphasis is different— on defects or blemishes, i.e., localized density variations, rather than illumination falloff (vignetting).

The Human Visual System

The human eye's Contrast Sensitivity Function (CSF), shown below, is a measure of the eye's MTF response. It is limited by the eye's optical system and cone density at high spatial (or angular) frequencies and by signal processing in the retina (neuronal interactions; lateral inhibition) at low frequencies. Various studies place the peak response at bright light levels between 6 and 8 cycles per degree.The CSF formula, which has the form k1f exp(-k2f ), is described in the page on Subjective Quality factor (SQF).

Constrst Sensitivity Function
Contrast sensitivity function

The human eye is sensitive to relative luminance differences. That's why we think of exposure in terms of zones or f-stops, where changing exposure by one f-stop or zone means halving or doubling the light. The smallest luminance difference the eye can distinguish in bright light (ΔL) is expressed by the Weber-Fechner law,
ΔL/L = 0.01

(G. Wyszecki & W. S. Stiles, "Color Science," Wiley, 1982, pp. 567-570). This is a relative difference of 1%. The thresholds, described below, are derived from this number (though they're typically larger in practice).

The coincidence

In order to get good blemish readings you must

  • filter out high spatial frequencies to remove noise— random variation of pixels caused by photons and thermal effects, which should not be misinterpreted as blemishes,
  • filter out low spatial frequencies to remove gradual pixel level changes caused by lens vignetting.

This filtering bears a curious resemblance to the contrast sensitivity function (though for practical reasons it's not an exact replica).

Algorithm

Lowpass and Highpass filtering  (familiar if you have a background in Electrical Engineering)

  • A lowpass filter (LPF) attenuates high frequencies, i.e., passes low frequencies. The most frequent application is noise reduction.
  • A highpass filter (HPF) attenuates low spatial frequencies, i.e., passes high frequencies, and removes the dc (zero frequency) component of the signal. The mean value of a signal after passing through an HPF is zero. To display such a signal as an image, an artificial dc level (typically equal to the mean of the original signal) has to be added. Highpass filtering reduces gradual changes in the signal (for example, pixel level variation caused by lens vignetting, i.e., Light Falloff).
  • A bandpass filter is a combined lowpass/highpass filter. The human eye is a bandpass filter.

Filters are characterized by bandwidth (typically the frequency where the ratio of output to input power (the transfer function) falls to 0.5, and by the rate of rolloff, which is more rapid for the gaussian filters than for exponential filters (selectable in the input dialog box). The word "bandwidth", which has become widely used in English slang, has its origins in Electrical Engineering.

If the original (unfiltered) image contains a tiny speck (perhaps a dead or hot pixel), a lowpass filter will broaden it and reduce its amplitude. For the human eye, the speck will be visible if its amplitude is large enough— if ΔL/L is greater than a threshold, which must be at least 0.01, as described above, for large objects with well-defined boundaries. The threshold for small objects is typically higher.

Instructions

To prepare an image for Blemish Detect,


SphereOptics integrating sphere

To obtain truly even illumination
for precision scientific measurements you'll need an integrating sphere from a supplier such as Image Engineering, SphereOptics, Labsphere, or Electro-Optical Industries (EOI).
The SphereOptics system on the right is about $8,000, including variable attenuator, power supplies, operating software, and calibration. It is available in sizes from 4 to 76 inches.

The Image Engineering Spherical Transparency Illuminator LE6 was designed for a variety of photographic applications. A mechanical shutter can dim the light down to 1% of the maximum illumination without changing the color temperature.

The DSC Labs Ambi Illuminator also provides extremely even illumination from a variety of external light sources. It is excellent for illuminating transparencies.

Integrating spheres aren't cheap. Controlling Veiling Glare in an Optical Imaging System by Amber Czajkowski (University of Arizona) contains a description of a really neat do-it-yourself integrating sphere project, based on stainless steel balls from http://www.gazingballoutlet.com, which sells balls up to 30 inches (0.75 meters) in diameter! A 16 inch (40 cm) ball is under $100 USD.

Other less expensive alternatives include Kyoritsu calibrated light sources (especially the pattern light boxes), available in the North America from C.R.I.S. Tsubosaka (Japan) also has some interesting products. There are no obvious US or European distributors.
Also of interest: DNP Light boxes.

 

To run Blemish Detect,

Input dialog box

The input dialog box appears after the image file has been selected.

Imatest Studio- Light Falloff input dialog box
Input dialog box

The blue region to the left of the filter response plot contains the blemish filter and detection settings.

The filter response plot, to the right of the Filter area, shows the filter response curves. The blue (lower) curve is the combined LPF and HPF response. The black (upper) curve is the combined response normalized to a maximum value of 1.0; this is the curve used for the actual filter calculations.

The Preview image, below the filter response plot (to the right of the Plot area) gives a 280x200 pixel preview of the filtered image. It is updated whenever filter settings are changed, making it useful for tuning. Preview displays include

Original image Original image for reference. Not affected by settings.
Image with blemish filter Filtered image. Shows the effects of the filters on blemishes. Since only a small (280x200) segment of the original image is shown, does not show the suppression of long-range variation from the highpass filtering.
Pseudocolor image- linear The blemish-filtered image in pseudocolor.
Pseudocolor image- spot emphasis The blemish-filtered image in pseudocolor with spot emphasis: shows deviation from the local average. Values above 0 are white. Values below -0.1 are black.
Pseudocolor image- > threshold The blemish-filtered image in pseudocolor showing only regions below (–) the threshold. Higher values are white. Values below -0.1 are black.

The Preview image location can be changed by pressing Preview location, and dragging the 280x200 pixel crop with the mouse. The final crop is shown in red. It should include blemishes of interest (above or below the threshold).

The Plot region specifies which figures to plot. The figures are described in Detail in the Results section, below.

The Settings region lets you enter settings that affect the results.

Hot & dead pixel dialog area

Because signal processing— especially JPEG compression— can cause these values to shift, you can use the sliders to set the detection threshold between 6-255 for hot pixels and 0-249 pixels for dead pixels. (The extreme values are for measurements made on white or black fields.) Clicking on < or > at the ends of the sliders adjusts the threshold by 1. The default values are 252 and 4, respectively. Settings are saved between runs. JPEG files must be saved at the highest quality level for this feature to work; isolated hot and dead pixels tend to be smudged at lower quality levels. Details are described in Light Falloff: Imatest Master .

Tuning

It is very important to set the key parameters of Blemish Detect so detected errors correspond to visible defects— to minimize both "false positives" and "false negatives".

The key parameters are

Test image

(A much more sophisticated approach is under development, but the image below is a start.)

Print or display the full-sized version of the image shown below, which you can download by clicking here or on the image itself. The image should viewed under the typical conditions for the product under development as well as for the largest angular field of view that you expect.

Use it to set the key parameters so that spots you consider to be objectionable are above the threshold and spots that are not objectionable are not. If small spots appear to be too strong in the Blemish plot (described below), decrease the lowpass filter frequency (move the slider to the left).

Click here or on the link above to download the full image (8 megapixels; 2.5MB)
Blemish Detect calibration image. Details shown below.
Click on the image to download the full-sized version (8 megapixels; 2.5MB)

Results

Image figures (original and filtered)

Several image figures are available. These figures are intended to facilitate the setup of filter and threshold parameters by making it convenient to compare images (original or processed) with blemish-filtered results (displayed in pseudocolor). Note that these plots are not anti-aliased, so vertical and horizontal nonuniformities (lines) may appear exaggerated in the original (unzoomed) display. To get an accurate impression, you must zoom in by clicking on an area of interest or drawing a rectangle. Double-click to zoom back out. The image illustrated below has three sequences of synthesized blemishes, differently sized, from weak to strong.

Test image (original; reduced)
Original image (shown reduced) with synthesized blemishes

Original test image (cropped)


Original image, shown cropped with enlarged spots.

When setting filter parameters (LPF and HPF cutoff frequencies as well as thresholds) this pattern should be observed carefully at appropriate magnification levels.

Blemish-filtered image, cropped

Blemish-filtered (HPF and LPF) image, cropped and enlarged

This image has been filtered to remove long-range density variations (typically from vignetting) as well as noise The blemish plot (primary results image), shown below, is derived directly from this image. The maximum density of spots should be closely related to the spot visibility in the unfiltered image, above.

Original image with HPF crop

Highpass-filtered image

This image shows the effects of the highpass filter only.

Original image with HPF and noise boost


Highpass filtered-image with noise boosted 10X

This plot maximizes the display of blemishes and noise, in distinction to the blemish-filtered plots that show blemishes, but minimize noise. Tiny defects are exaggerated.


Blemish plot (the primary results display)

The blemish plot is the key results display.

Primary blemish results image
Blemish display with spot emphasis: the primary results of Blemish Detect.

Pseudocolor crop: spot emphasis
Enlarged blemishes (spot emphasis)


Spot emphasis clamps the filtered blemish image to a maximum value of 0 and a minimum value of -0.1. This makes the (darker) blemishes much more visible than in the linear (unclamped) image below.

The bottom row is displayed when Results, histogram & Response is checked in the input dialog box. The filter response curve is shown on the left: the lower blue curve is the combined LPF + HPF response. The upper black curve is the response normalized for a maximum value of 1.0 (used for the calculations). The table in the middle displays the number of errors (N Err), the minimum value (Min), and (–) the threshold level (Thr) for the image as a whole as well as for each of the 9 sections and the average vertical and horizontal lines. A histogram of levels is displayed on the right.

Blemish pseudocolor linear display
Linear blemish display (enlarged blemishes)

Line blemish plot

Lines tend to be more visually prominent that spots or blemishes of similar size. For this reason, they are detected with a different threshold (generally lower; 0.005 in the image below). The plots below are for vertical and horizontal lines in the image. The same filtering is used as for spots. This plot is for an image where significant vertical banding (lines) was visible in the 10x noise boosted plot, but the banding wasn't visible in in the original image displayed full sized (to get around anti-aliasing problems when displayed in reduced size in Matlab figures.

Line display
Line blemish plot

The ends of the lines, which are not included in the analysis because of end effects (in the FFT routine) are shown in light gray.

CSV and XML output files

The CSV and XML output files contain additional statistics. Most have obvious meanings.

Contact Imatest if you need additional .CSV output. The optional XML output file contains results similar to the .CSV file. Its contents are largely self-explanatory. It is stored in [root name].xml. It will be used for a database product under development. Contact us if you have questions or suggestions.

Saving results

At the end of the run, a dialog box for saving results appears. It allows you to select figures to save and choose where to save them. The default is subdirectory Results in the data file directory. You can change to another existing directory, but new results directories must be created outside of Imatest— using a utility such as Windows Explorer. (This is a limitation of this version of Matlab.) The selections are saved between runs. You can examine the output figures before you check or uncheck the boxes. Figures, CSV, and XML data are saved in files whose names consist of a root file name with a suffix for plot type and channel (R, G, B, or Y) and extension. Example: IMG_9875_ISO1600_RGB_f-stop_ctrG.png. The root file name defaults to the image file name, but can be changed using the Results root file name box. Be sure to press enter. Checking Close figures after save is recommended for preventing a buildup of figures (which slows down most systems) in batch runs. After you click on Yes or No, the Imatest main window reappears.

Figures can be saved as either PNG files (a standard losslessly-compressed image file format) or as Matlab FIG files, which can be opened by the Open Fig file button in the Imatest main window. Fig files can be manipulated (zoomed and rotated), but they tend to require more storage than PNG files. They are especially nice because 3D files can be reopened and rotated, but you should exercise caution because 3D files can be very large— often several megabytes.

The CSV and XML files contain EXIF data, which is image file metadata that contains important camera, lens, and exposure settings. By default, Imatest uses a small program, jhead.exe, which works only with JPEG files, to read EXIF data. To read detailed EXIF data from all image file formats, we recommend downloading, installing, and selecting Phil Harvey's ExifTool, as described here.




Subscribe to the Imatest Newsletter