## sharpness – How to calculate MTF ? Need help with the formula

I’m trying to reproduce MTF chart programmatically but I’m stuck at some point.

I’m starting with a clean bar chart like this:

I then take a picture of this pattern with a smartphone (printed on HD quality paper, no gloss, no texture, …) and I get something like this: (there is a big of distortion)

I used the following page to understand how MTF is calculated:
https://www.imatest.com/docs/sharpness/

With my script, I’m basically scanning all vertical lines one by one, I scan pixels one by one from top to bottom for each line and I get the min and max value for luminance (I get the LAB value for each picture and I take the “l” value).

For the first step (amplitude), I get the following graph for my “perfect” example:

And when I do the same with the picture I took, I get something like this:

So far, it seems to be in line with what I see on the Imatest page except that my values seem inverted and that I go above 100 while I only apply the following formula: C(f)=Vmax−Vmin/Vmax+Vmin

Now my problem is that I can’t get to the MTF formula, if I apply MTF(f)=100%×C(f)C(0), I get exactly the same graph. My maths are rusty and maybe I’m missing something somewhere.

What I’m trying to achieve is to give a easy to understand score to sharpness. MTF is a good starting point but in the end, I would like to give a score like an average. I know it’s not accurate because the center is sharper than the edge but at least it would allow to rank sharpness in a more or less neutral way.

Any idea on how I can build the MTF chart or how I could assign a final score?

Thanks

## sharpness – How to calculate MTF programmatically ? (with PHP for example)

I’m trying to reproduce MTF chart programmatically but I’m stuck at some point.

I’m starting with a clean bar chart like this:

I then take a picture of this pattern with a smartphone (printed on HD quality paper, no gloss, no texture, …) and I get something like this: (there is a big of distortion)

I used the following page to understand how MTF is calculated:
https://www.imatest.com/docs/sharpness/

With my script, I’m basically scanning all vertical lines one by one, I scan pixels one by one from top to bottom for each line and I get the min and max value for luminance (I get the LAB value for each picture and I take the “l” value).

For the first step (amplitude), I get the following graph for my “perfect” example:

And when I do the same with the picture I took, I get something like this:

So far, it seems to be in line with what I see on the Imatest page except that my values seem inverted and that I go above 100 while I only apply the following formula: C(f)=Vmax−Vmin/Vmax+Vmin

Now my problem is that I can’t get to the MTF formula, if I apply MTF(f)=100%×C(f)C(0), I get exactly the same graph. My maths are rusty and maybe I’m missing something somewhere.

What I’m trying to achieve is to give a easy to understand score to sharpness. MTF is a good starting point but in the end, I would like to give a score like an average. I know it’s not accurate because the center is sharper than the edge but at least it would allow to rank sharpness in a more or less neutral way.

Any idea on how I can build the MTF chart or how I could assign a final score?

Thanks

## Using MTF, how can I discover the smallest detail a smartphone camera can resolve for use in generating QR codes?

Since most camera lens combinations have variable MTF across the field (that is, the system can usually resolve finer details in the center of the frame than on the edges and in the corners), there is no single “magic number”, even for a specific camera/lens combo.

Then there’s the variability introduced by low light/high ISO that reduces the amount of detail that the same system can resolve compared to when that system is used under more ideal conditions.

There’s also the fact that most scans will not be made with the phone perfectly aligned with the QR code. So the minimum theoretically possible size under “perfect” conditions with the target framed perfectly level by the phone and perfectly perpendicular to the phone’s sensor won’t work if the phone is tilted and/or rotated several degrees with respect to the target QR code.

In the end you have to “aim low” if you want to create QR codes that can be compatible with a large majority of phones.

As for the QR codes themselves, the major variables are:

• Scanning distance. A QR code on a billboard that will be scanned from 40-50 feet needs to be quite a bit larger than a QR code on a business card that will be scanned from about 12 inches.
• The amount of data encoded. The more data you want to encode, the more discrete squares called data units arranged in rows and columns your QR code will need, and the larger it must be for each row and column to be the same size. A 25×25 QR code with 625 data units can be smaller than a 125×125 QR code with 2132 data units.
• The design features of your QR code. If you want to make it something other than a plain B&W “bar code” looking QR code, you need to include plenty of error correction (which increases the total data needed to communicate the same amount of information). QR codes that have colors or are embedded in an image attract more scans than plain B&W QR codes do.
• Printing considerations. Since printers often scale images, using vector graphics is usually best for QR codes. There also needs to be good contrast between the QR code and the background upon which it is printed.

There are a variety of resources on the net that address this. Here are four that are helpful:

QR Code Minimum Size: Calculate ideal size for your use case
What Size Should a QR Code Be in Relation to Scan Distance?
What is the ideal print size of a QR Code?
QR Code Minimum Size: How Small Can a QR Code Be?

## Discover smallest resolvable detail of smartphone camera with MTF

Given a chart I created myself, resembling e-sfr charts, a smartphone and a MTF plot, how could I discover the smallest resolvable detail, dimension wise ? The problem with smartphones is that we don’t always have all of the technical hardware information.

To give more context, I’d like to create the smallest QR code that could be read by a smartphone camera when printed. Mine in the occurrence is the Xiaomi MI 9 SE, however, I’d like it to work with any.

## How do I transform LP/pixel to LP/PH in MTF plot?

I’m working on computing MTF plots for smartphone camera. I’ve a working code in Python inspired by plenty of codes found online, MATLAB, Peter Burns and his sfrmat etc.. which computes the data from a chart I’ve created using the slanted edge algorithm, and is displayed as Line Pairs per Pixels.

However, to compare smartphones between them, I’ve found that displaying the MTF plot with Line Pairs per Picture Height should be better. How can i go from one to the other ?
Also, as I extract a ROI of the chart, is the Picture Height the original one, or only of the ROI ?

Finally, I’ve seen on Imatest that they discuss Line Pairs per Object Distance (https://www.imatest.com/docs/sharpness/#freq_units) but I honestly don’t understand it. Can someone explain it a bit ? Could it be capable of giving information on the smallest possible details distinguishable ?

## mtf – What is considered a good / great LP/PH value?

After combing through ISO 12233 and reading multiple articles, I’m still unsure what LP/PH values are considered poor, good, or great. I just finished testing a Nikon D750 with an 18-70mm lens. I’m using Imatest to do the analysis. For example, I’m analyzing 9 regions of the sensor, and I’m getting values ranging from 486 LP/PH in the bottom left corner to 1261 in the center.

Lens MTF Test Info

30 lp/mm > 0.5 is very sharp
30 lp/mm > 0.3 is sharp if you sharpen a bit
30 lp/mm < 0.2 is getting soft

For a DX lens, the Picture Height (PH) is 16mm.
This results in (30LP/mm)*(16mm/PH) = 480 LP/PH.
This would suggest if MTF50 > 480 LP/PH is sharp.

However, on another forum, I saw a comment that said:

I find 1400LP/PH acceptable, but 2400+ preferable.

If 480 is very sharp, why would someone fine 1400 only acceptable?

Any assistance, reference, etc. would be .beneficial

## lens – How is the diffraction-limited MTF determined at a given contrast?

Tables and formulas for determining the MTF "absorbance" / "zero contrast" in lp / mm at a given diffraction limited system aperture are well known.

How is the theoretical maximum MTF determined at a given aperture that gives a certain nonzero contrast (eg, 50%, 10%, 20%, 90%)?