User:The Lamb of God/sandbox-Modulation Transfer Function (MTF)

The Modulation Transfer Function (MTF) is used to approximate the position of best focus of an infrared imaging system. In an imaging system, best focus is typically achieved when the MTF is between 0.4 and 0.6; most often at 0.5 (50% cutoff frequency of the MTF) MTF is inversely related to the MRTD, which is a measure of an infrared sensor's abillity to resolve temperature difference. MTF is defined as the discrete fourier transform of the LSF (Line Spread Function). The LSF can be calculated by two different methods. One includes measuring the LSF directly from an idealized line approximation provided by an image of a slit target. The other involves differentiating the ESF (Edge Spread Function).

ESF evaluation
An operator defines a box area encompassing the edge of a knife-edge test target image back-illuminated by a blackbody. The box area is defined to be approximately 10% of the total frame area. The image pixel data is translated into a two-dimensional array (pixel intensity and pixel postition). The amplitude (pixel intensity) of each line within the array is normalized and averaged. This yields the edge spread function (ESF)

ESF calculations
$$ ESF = \frac{X - \mu\,}{\sigma\,} \qquad \qquad \sigma\, = \sqrt{\frac{\sum_{i=0}^{n-1} (x_i-\mu\,)^2}{n}} \qquad \qquad \mu\, = \frac{\sum_{i=0}^{n-1} x_i}{n} $$


 * where...
 * $$ESF\,$$ = the output array of normalized pixel intensity data
 * $$X\,$$ = the input array of pixel inensity data
 * $$x_i\,$$ = the ith element of $$X\,$$
 * $$\mu\,$$ = the average value of the pixel intensity data
 * $$\sigma\,$$ = the standard deviation of the pixel intensity data

LSF evaluation
The Line Spread Function can be found using two different methods. It can be found directly from an ideal line approximation provided by a slit test target or it can be derived from the Edge Spread Function. Using the latter method the Lines Spread Function, abreviated LSF, is defined as the the first derivative of the Edge Spread Function, which is differentiated using numerical methods.

LSF calculations
$$LSF\,$$ = the derivative $$(\frac{dx}{dy})$$ of the $$ESF\,$$

Since the $$ESF\,$$ can not be differentaited analytically, it is numerically approximated using the centered difference approximation of the first derivative. i.e.

$$ LSF = \frac{dx}{dy} \approx \frac{\Delta x}{\Delta y} \qquad \qquad LSF = \frac{x_{i+1} - x_{i-1}}{2(y_{i+1} - y_i)} - O(\Delta y^2)$$


 * where...
 * $$i\,$$ = the index i = 1,2,...,n-1
 * $$x_i\,$$ = $$i^{th}\,$$ pixel intensity corresponding to the $$i^{th}\,$$ pixel position
 * $$y_i\,$$ = the $$i^{th}\,$$ pixel position
 * $$O(\Delta y^2)\,$$ = the associated error of the numerical approximation (a function of the step size squared)

MTF Evaluation
The  Modulation Transfer Function (MTF) is defined as the discrete fourier transform of the Line Spread Function. Thus, given the LSF, the MTF is approximated numerically. This data is graphed against the spatial frequency data. A sixth order polynomial is fitted to the MTF vs. spatial frequency curve to remove any trends. The 50% cutoff frequency is determined to yield the coressponding spatial frequency. Thus, the approximate position of best focus of the Unit Under Test is determined from this data.

MTF calculations
The Fourier transform of the LSF can not be determined analytically by the following equations:


 * $$MTF = \mathcal{F} \left[ LSF \right] \qquad \qquad MTF = \int f(x)^{-i 2 \pi\, x s}\, dx$$

Therefore, the Fourier Transform is numerically approximated using the discrete Fourier transform $$\mathcal{DFT}$$.

$$MTF = \mathcal{DFT}[LSF] = Y_k = \sum_{n=0}^{N-1} y_n e^{-ik \frac{2 \pi}{N} n} \qquad from \,\,\, k = 0 \,\,\, to \,\,\, k = N-1 $$




 * where...
 * $$Y_k\,$$ = the $$k^{th}$$ value of the $$MTF\,$$
 * $$N\,$$ = number of data points
 * $$n\,$$ = index
 * $$k\,$$ = $$k^{th}$$ term of the $$LSF\,$$ data
 * $$y_n\,$$ = $$n^{th}\,$$ pixel position
 * $$i\,$$ = complex number

Since, most computer software is not able to compute complex numbers directly Euler's identity is implemented to break the transform into seperate  real and complex terms.
 * $$ e^{\pm ia} = cos(a) \, \pm \, isin(a) $$

$$MTF = \mathcal{DFT}[LSF] = Y_k = \sum_{n=0}^{N-1} y_n [cos(k\frac{2 \pi}{N} n) - isin(k \frac{2 \pi}{N} n)] \qquad from \,\,\, k = 0 \,\,\, to \,\,\, k = N-1 $$

The MTF is then plotted against spatial frequecny and all relevant data concerning this test can be determined from that graph.