## How many megapixels? A worked-out example

Recently, my faithful Nexus 5X "died" of a disease that eventually affects everyone of its kind:
the dreadful boot loop. The replacement was a Google Pixel 3a XL, and I was curious
to know the true resolution of its camera.

The rationale of the following calculations can be found in the articles
Depth of field vs sensor size
and How many megapixels does your equipment have?
The relevant specs of the Pixel camera are: aperture f/1.8, sensor size
5.76mm x 4.29mm.

First we calculate the "Airy disk" or diffaction disk. This is the sharpest spot
or smaller circle of confusion the lens can project upon the sensor, with perfect
focus.

coc = 2.44 . λ . f
λ = average light wavelength
coc = 2.44 . 0.5µm . 1.8
coc ~= 2.2µm

The result above hinges on two factors: the lens aperture (the wider, the better) and
the constant 2.44, which is different accordingly to the version of the formula. The
smaller the constant is, the more "optimistic" is the estimate. For example, in Wikipedia
the adopted constant is 1.22.

Dividing sensor's width and height by the diffraction disk, we find a resolution of

h = 5760 / 2.2 = 2618px
w = 4290 / 2.2 = 1950px
mp = 2618 x 1950 = 5105100

In a first approximation, the effective resolution is 5.1 megapixels, not bad for a
smartphone. But we can count 1.5 pixel per circle of confusion, so

mp = 2618 x 1.5 x 1950 x 1.5 = 11486475

We find the optical resolution (11.4MP) is almost the same as the sensor
resolution (12.2MP). This is great; it means the sensor is well-matched with the
optical system. We can shoot at maximum resolution and actually get pictures with
such resolution, so we have room for cropping and other adjustments.