# Correcting nonuniformity in slanted-edge MTF measurements

Slanted-edge regions can often have __non-uniformity__ across them. This could be caused by uneven illumination, lens falloff, and photoresponse nonuniformity (PRNU) of the sensor.

Uncorrected nonuniformity in a slanted-edge region of interest can lead to an irregularity in MTF at low spatial frequencies. This disrupts the low-frequency reference which used to normalize the MTF curve. If the direction of the nonuniformity goes against the slanted edge transition from light to dark, MTF increases. If the nonuniformity goes in the same direction as the transition from light to dark, MTF decreases.

To demonstrate this effect, we start with a simulated uniform slanted edge with some blur applied.

Then we apply a simulated nonuniformity to the edge at different angles relative to the edge. This is modeled to match a severe case of nonuniformity reported by one of our customers:

Here is the MTF obtained from the nonuniform slanted edges:

If the nonuniformity includes an angular component that is parallel to the edge, this adds a sawtooth pattern to the spatial domain, which manifests as high-frequency spikes in the frequency domain. This is caused by the binning algorithm which projects brighter or darker parts of the ROI into alternating bins.

### Compensating for the effects of nonuniformity

Although every effort should be made to achieve even illumination, it’s not always possible (for example, in medical endoscopes and wide-FoV lenses).

* Imatest 4.5+* has an option for dealing with this problem for all slanted-edge modules (SFR and Rescharts/fixed modules SFRplus, eSFR ISO, SFRreg, and Checkerboard). It is applied by checking the “Nonuniformity MTF correction” checkbox in the settings (or “More” settings) window, shown on the right.

When this box is checked, a portion of the spatial curve on the light side of the transition (displayed on the right in Imatest) is used to estimate the nonuniformity. The light side is chosen because it has a much better Signal-to-Noise Ratio than the dark side. In the above image, this would be the portion of the the edge profile more than about 6 pixels from the center. Imatest finds the first-order fit to the curve in this region, limits the fit so it doesn’t drop below zero, then divides the average edge by the first-order fit.

The applied compensation flattens the response across the edge function and significantly improves the stability of the MTF:

### Summary

For this example, Imatest’s nonuniformity correction reduces our example’s -26.0% to +22.8% change in MTF down to a -3.5% to +4.7% change. This is an 83% reduction in the effect of the worst cases of nonuniformity.

MTF50 versus nonuniformity angle without [blue] and with [orange] nonuniformity correction

While this is a large improvement, the residual effects of nonuniformity remain undesirable. Because of this, we recommend turning on your ISP’s nonuniformity correction before performing edge-SFR tests or averaging the MTF obtained from nearby slanted edges with opposite transition directions relative to the nonuniformity to reduce the effects of nonuniformity on your MTF measurements further.

### Detailed algorithm

We assume that the illumination of the chart in the Region of Interest (ROI) approximates a first-order function, *L*(*d*) = *k*1 + *k*2*d*, where *d* is the horizontal or vertical distance nearly perpendicular to the (slanted) edge. The procedure consists of estimating *k*1 and *k*2, then dividing the linearized average edge by *L*(*d*).

*k*1 and *k*2, are estimated using the light side of the transition starting at a sufficient distance *d*_{N} from the transition center *x*_{center}, so the transition itself does not have much effect on the *k*1 and *k*2 estimate. To find *d*_{N} we first find the 20% width *d*_{20} of the line spread function (LSF; the derivative of the edge), i.e., the distance between the points where the LSF falls to 20% of its maximum value.

*d*_{N} = *x*_{center} + 2 *d*_{20}

If the edge response for *x* > *d*_{N} has a sufficient number of points, it is used to calculate *k*1 and *k*2 using standard polynomial fitting techniques. The result is a more accurate representation of the edge with the effects of nonuniformity reduced.

### Future work

Consider the 2D nonuniformity across the ROI before sampling the 1D average edge

Use an image of a flat-field to perform nonuniformity correction within Imatest

Consider the impact of noise which was not included in this study

Incorporate enhancements to the slanted-edge algorithms into future revisions of

__ISO 12233__

For any questions on how to do this, or how we can help you with your projects, please open an issue at the __Imatest Help Center__.