Math for Photography
On This Page
A key part of my photography practice is a custom-built relational database that I use to manage my catalog of images. As I developed that database, I encountered situations where I wanted to derive certain numerical values.
At least on its theoretical side, photography exhibits a beautiful mathematical harmony. When I see a formula, the database developer in me can’t resist integrating it into my photography database.
In this discussion, I present some of the things I’ve discovered about the mathematical side of photography and how one might use it in useful ways. It covers how to make calculations related to frame size, lens focal length, the three corners of the “exposure triangle”—aperture, exposure time, and sensitivity—and the effect that lens filters have on exposure.
Since I’m approaching this from the perspective of a database developer, I present formulas both as pure mathematical expressions as well as how those formulas would be implemented using T-SQL, the programming language of the Microsoft SQL Server database platform. The full script that generates and loads a demo database named PhotographyDemo is available here.
Many thanks go to Wayne Fulton for his articles here, here, and here. They played a key role as I attempted to wrap my head around the math behind photography.
Sensor Size, Crop Factor, and 35mm Equivalent Focal Length
The logic behind calculations involving sensor or frame size, crop factor, and 35mm equivalent focal lengths applies to both digital sensors and half-frame film cameras.
Sensor or Film Frame Diagonal Length
Every camera has some kind of medium that detects light. That medium has width and height dimensions, of course.
With my high school geometry in mind, I knew that calculating the length of a rectangle diagonal was a relatively simple matter. Remember the Pythagorean theorem?
a2 + b2 = c2
The square of both the width (a) and the height (b) of a rectangle are, when added together, equal to the length of its diagonal (c).
It follows that adding the squares of both the width and the height of a rectangle and calculating the square root of that sum will give you the diagonal length of that rectangle:
c = √(a2 + b2)
Expressing this in T-SQL is very straightforward. In a database table that holds camera-related data points including sensor width and height in millimeters (SensorSizeWidth and SensorSizeHeight), I implemented this calculation as a computed column named SensorSizeDiagonal using this logic:
sqrt(square(SensorSizeWidth) + square(SensorSizeHeight))
Crop Factor
The shadow that 35mm film photography casts even on digital photography is formidable. That older medium’s proportions serve as a standard for thinking about various digital photography specs in a more uniform way. Cropped digital camera sensors are called as such because they are smaller than the standard 24 x 36mm frame size of a 35mm film exposure.
When thinking about a lens’s focal length, a camera’s crop factor comes into play. In a nutshell, a standard 50mm “normal” lens acts like a short telephoto lens on a digital camera with a cropped sensor (Micro Four Thirds system cameras, APS-C digital cameras, and so on). One uses a camera’s crop factor to convert the actual focal length of the lens to its 35mm equivalent.
The calculation uses very similar logic as that for frame diagonal length discussed above. Given the width (a) and the height (b) of a recording medium (digital sensor or film frame), the crop factor (CF) is calculated as:
CF = √(242 + 362) / √(a2 + b2)
The T-SQL expression of this is also very straightforward. Again, in a database table that holds camera-related data points including sensor width and height in millimeters (SensorSizeWidth and SensorSizeHeight), I implemented this calculation as a computed column named CropFactor using the following logic:
sqrt(square(24) + square(36)) / sqrt(square(SensorSizeWidth) +
square(SensorSizeHeight))
For a more detailed discussion of crop factor, see the Wikipedia article on the topic.
35mm Equivalent Focal Length
With crop factor known, calclating the 35mm equivalent focal length of a lens is a simple matter of multiplying the lens’s actual focal length by the crop factor of the camera that that lens is mounted on.
Expressed as T-SQL code, the calculation involves simply multiplying the value in LensFocalLength, a column that holds lens focal length, by the computed column named CropFactor that I describe above:
LensFocalLength * CropFactor
For a more detailed discussion of 35mm equivalent focal length, see the Wikipedia article on the topic.
The Exposure Triangle
A great deal of math serves as the foundation for exposure theory. A central idea of that theory is the exposure triangle. Do an internet search on this topic and you’ll indeed come up with many hits.
Essentially, a photographic image’s exposure is determined by three things: lens aperture, exposure time, and the sensitivity of the recording medium (a digital sensor or film emulsion).
Each element has a reciprocal relationship with each other. If you change one of these elements and move another in an opposite direction by the same proportion (usually in whole or fractional increments called “stops”), you will make an equivalent exposure. One stop equals the doubling or the halving of light from the adjacent stop.
Each of the three corners of the exposure triangle can be considered in terms of stops. Crucially for the purpose of this discussion, one can also number those stops in sequential order from a standardized beginning point: stop number zero.
Aperture
A lens’s aperture determines how much light that lens admits through to the recording medium. It is expressed as an F-number, or the ratio of the lens’s focal length divided by the diameter of the exit pupil.
F-numbers can be indicated in full stops:
f/1, f/1.4, f/2, f/2.8, f/4, f/5.6, f/8, f/11, f/16, etc...
half stops:
f/1, f/1.2, f/1.4, f/1.7, f/2, f/2.4, f/2.8, f/3.3, f/4, etc...
or third stops:
f/1, f/1.1, f/1.2, f/1.4, f/1.6, f/1.8, f/2, f/2.2, f/2.5, f/2.8, etc...
using nominally standardized numbers that simplify their representation on a lens or camera display.
Starting from f/1, or stop number zero, one can use math to calculate the progression of precise F-numbers (N) by whole stops. Using this formula:
N = √(2)AV
you can see how nominal and precise values correspond. Here is the progression between f/1 and f/16:
Stop Number | Nominal F-number | Precise F-number |
---|---|---|
0 | 1 | 1 |
1 | 1.4 | 1.414213562 |
2 | 2 | 2 |
3 | 2.8 | 2.828427125 |
4 | 4 | 4 |
5 | 5.6 | 5.656854249 |
6 | 8 | 8 |
7 | 11 | 11.3137085 |
8 | 16 | 16 |
Way back in the day, non-standardized scales existed for expressing lens aperture, but in my experience it’s only on really old lenses that one sees these scales.
For more information, see the Wikipedia articles on aperture and F-number and Wayne Fulton’s detailed explanation of nominal and precise exposure settings.
Exposure Time
Exposure time concerns how long a recording medium is exposed to light. It is expressed as the speed of the camera body’s shutter most often in fractions of a second.
Shutter speeds can be indicated in full stops:
1/250, sec., 1/125, sec., 1/60, sec., 1/30, sec., 1/15, sec., 1/8, sec., etc...
half stops:
1/250 sec., 1/180 sec., 1/125 sec., 1/90 sec., 1/60 sec., etc...
or third stops:
1/250 sec., 1/200 sec., 1/160 sec., 1/125 sec., etc...
using nominally standardized numbers that simplify their representation on a camera body’s shutter speed dial.
Like aperture, a slight difference exists between nominal and precise exposure times. Here is the progression between 1/1000 sec. and 30 sec.:
Stop Number | Nominal Exposure Time | Precise Exposure Time |
---|---|---|
-10 | 1/1000 sec. | 1/1024 sec. |
-9 | 1/500 sec. | 1/512 sec. |
-8 | 1/250 sec. | 1/256 sec. |
-7 | 1/125 sec. | 1/128 sec. |
-6 | 1/60 sec. | 1/64 sec. |
-5 | 1/30 sec. | 1/32 sec. |
-4 | 1/15 sec. | 1/16 sec. |
-3 | 1/8 sec. | 1/8 sec. |
-2 | 1/4 sec. | 1/4 sec. |
-1 | 1/2 sec. | 1/2 sec. |
0 | 1 sec. | 1 sec. |
1 | 2 sec. | 2 sec. |
2 | 4 sec. | 4 sec. |
3 | 8 sec. | 8 sec. |
4 | 15 sec. | 16 sec. |
5 | 30 sec. | 32 sec. |
In practice, the difference between nominal and precise values—for example, 1/1000 sec. and 1/1024 sec., respectively—is negligible.
Stop number zero is 1 sec. with shorter exposure times being represented as negative stop numbers and longer ones as positive stop numbers.
On older camera bodies from the 1950s and earlier, one might see the older, non-standardized scale indicated on the shutter speed dial(s). Around the late 1950s or so, camera makers adopted the modern system.
For more information on shutter speed, see the Wikipedia article on the topic and Wayne Fulton’s detailed explanation of nominal and precise exposure settings.
Sensitivity of Recording Media
The third corner of the exposure triangle is the sensitivity of the recording medium.
Unlike film, where the physical size of silver halide crystals determines the emulsion’s sensitivity (larger size equals more sensitivity but also grainier images), a digital camera sensor behaves differently. In part 1 and part 2 of his 2020 Digital Photography Review article on entitled “The Ins and Outs of ISO,” Richard Butler explains that one cannot change the sensitivity of a digital camera’s sensor itself. It detects light only insofar as its design permits, no more and no less. Everything that happens after that is a matter of processing.
In fact, as Butler points out in part 2, digital cameras produced before adoption of the 2006 ISO definition simply added or subtracted however many stops of amplification were necessary for a particular ISO setting. My own catalog of images from those early digital cameras bears this out: many of those early digital cameras did not even record an ISO setting with image EXIF metadata.
And in the December 2021 issue of Sky and Telescope, Richard S. Wright, Jr., writes that “a digital camera has an innate, fixed sensitivity, and there’s nothing that can be done to make its sensor more or less responsive to the light reaching it.” A sensor can merely “simulate ISO changes through digital scaling—multiplying or dividing the numeric values of the pixels that make up an image. That’s right,” Wright added bluntly, “in today’s digital cameras, ISO is fake.”
But whatever the case may be where the actual or simulated sensitivity of a recording medium is concerned, I consider the matter of sensitivity uniformly for the purpose of this dicussion regardless of whether that medium is film or a digital sensor.
The system used to represent the physical or effective sensitivity of the recording medium derives from the ASA (American Standards Association) EI (exposure index) system from the mid-1940s. The same numbering system is used for a digital camera sensor’s ISO (International Organization of Standards) setting.
To be clear, I tend to use the acronym ASA when referring to film speed and ISO when referencing the sensitivity setting of a digital sensor. In my programming code, however, I use the latter in the interest of succinctness.
Using a numbering system whereby each full-stop number is a doubling of the prior full-stop number, sensitivity can be indiciated in full stops:
100, 200, 400, 800, 1600, 3200, 6400, etc...
half stops:
100, 140, 200, 280, 400, 560, 800, etc...
or third stops:
100, 125, 160, 200, 250, 320, 400, etc...
Similar to aperture and exposure time, a slight difference exists between nominal and precise sensitivity but only where fractional stops are concerned. Here is the progression between ASA/ISO 100 and 1600:
Stop Number | Nominal ASA/ISO | Precise ASA/ISO |
---|---|---|
0 | 100 | 100 |
0.33 | 125 | 125.992104989487 |
0.5 | 140 | 141.42135623731 |
0.67 | 160 | 158.74010519682 |
1 | 200 | 200 |
1.33 | 250 | 251.984209978975 |
1.5 | 280 | 282.842712474619 |
1.67 | 320 | 317.48021039364 |
2 | 400 | 400 |
2.33 | 500 | 503.96841995795 |
2.5 | 560 | 565.685424949238 |
2.67 | 640 | 634.96042078728 |
3 | 800 | 800 |
3.33 | 1000 | 1007.9368399159 |
3.5 | 1100 | 1131.37084989848 |
3.67 | 1250 | 1269.92084157456 |
4 | 1600 | 1600 |
The history of stop numbers for ASA/ISO settings is a bit messy. Wayne Fulton’s website has a detailed explanation of the matter. In a nutshell, the beginning of ASA/ISO stop numbers switched from 1 to 100 around the early 1960s. For my purposes, I use the less pure but more practical modern method: ASA/ISO 100 is stop number zero.
Also see the Wikipedia article on film speed and digital camera sensitivity.
Adding Stops to an Exposure Setting
There are times when I want to increment an exposure setting by a given number of stops. Thankfully, there are mathematical ways to do this.
Yet again, Wayne Fulton’s detailed discussion at scantips.com was enormously helpful to me in figuring this out.
Adding Stops to an F-number
The mathematical formula for increasing or decreasing an F-number by a given number of stops is:
N * (√(2)AV)
where N is the F-number in question and AV is the number of stops to increase or decrease that F-number by.
See the Wikipedia article on F-number and the calculator at computingbits.com for more.
The following T-SQL function named dbo.FNumberAddStops increases or decreases a given F-number by the number of stops passed into the function:
create function dbo.FNumberAddStops
(
@FNumber float,
@StopsIncrease float
)
returns float
as
begin
return (
@FNumber * power(sqrt(2),
@StopsIncrease)
);
end
go
This query:
select FNumber,
StopsIncrease,
round(dbo.FNumberAddStops(
FNumber,
StopsIncrease),
1) as NewFNumber
from (
select 1.4, 2 union all
select 5.6, 1.5 union all
select 11, -3.33
) u (FNumber, StopsIncrease);
returns these results:
FNumber StopsIncrease NewFNumber
------- ------------- ----------
1.4 2.00 2.8
5.6 1.50 9.4
11.0 -3.33 3.5
Because I am passing in nominal values, this function dutifully returns increased or decreased F-numbers by the exact amount that I specified upon calling the function.
Adding Stops to Shutter Speed
The mathematical formula for increasing or decreasing shutter speed setting by a given number of stops is:
2log2(T) + AV
where T represents shutter speed in seconds and AV is the number of stops to increase or decrease that shutter speed by.
The following T-SQL function named dbo.ExposureTimeSecondsAddStops increases or decreases a given shutter speed by the number of stops passed into the function:
create function dbo.ExposureTimeSecondsAddStops
(
@ExposureTimeSeconds float,
@StopsIncrease float
)
returns float
as
begin
return (
power(cast(2 as float),
log(@ExposureTimeSeconds, 2) + @StopsIncrease)
);
end
go
This query:
select ExposureTimeSeconds,
StopsIncrease,
round(dbo.ExposureTimeSecondsAddStops(
ExposureTimeSeconds,
StopsIncrease),
10) as NewExposureTimeSeconds
from (
select 1./250, 2 union all
select 1./500, 1.5 union all
select 1./30, -3.33
) u (ExposureTimeSeconds, StopsIncrease);
returns these results:
ExposureTimeSeconds StopsIncrease NewExposureTimeSeconds
------------------- ------------- ----------------------
0.004000 2.00 0.016
0.002000 1.50 0.0056568542
0.033333 -3.33 0.0033147022
Because I am passing in nominal values, this function dutifully returns increased or decreased shutter speeds by the exact amount that I specified upon calling the function.
Adding Stops to ASA/ISO Speed
The mathematical formula for increasing or decreasing ASA/ISO speed setting by a given number of stops is more or less identical to that used for shutter speed. It is:
2log2(S) + AV
where S represents ASA/ISO speed and AV is the number of stops to increase or decrease that shutter speed by.
The following T-SQL function named dbo.ISOSpeedAddStops increases or decreases a given ASA/ISO speed by the number of stops passed into the function:
create function dbo.ISOSpeedAddStops
(
@ISOSpeed float,
@StopsIncrease float
)
returns float
as
begin
return (
power(cast(2 as float),
log(@ISOSpeed, 2) + @StopsIncrease)
);
end
go
This query:
select ISOSpeed,
StopsIncrease,
round(dbo.ISOSpeedAddStops(
ISOSpeed,
StopsIncrease),
0) as NewISOSpeed
from (
select 100, 2 union all
select 400, 1.5 union all
select 1600, -3.33
) u (ISOSpeed, StopsIncrease);
returns these results:
ISOSpeed StopsIncrease NewISOSpeed
-------- ------------- ----------------------
100 2.00 400
400 1.50 1131
1600 -3.33 159
Because I am passing in nominal values, this function dutifully returns increased or decreased ASA/ISO speeds by the exact amount that I specified upon calling the function.
Number of Stops Between Two Exposure Settings
Sometimes it’s useful to have a way to determine how many stops are between two exposure settings.
Number of Stops Between Two F-numbers
The mathematical formula for determining how many stops are between two F-numbers is:
log2(N1 / N2) / log2(√(2))
where N1 and N2 are the two F-numbers being compared.
My thanks go to Paulo Renato and his article on calculating F-stops for help on figuring this out.
The following T-SQL function named dbo.FNumberStopsDifference returns the number of stops between two F-numbers:
create function dbo.FNumberStopsDifference
(
@FNumber1 float,
@FNumber2 float
)
returns float
as
begin
return (
log(@FNumber2 / @FNumber1, 2) / log(sqrt(2), 2)
);
end
go
This query:
select FNumber1,
FNumber2,
round(dbo.FNumberStopsDifference(
FNumber1,
FNumber2),
1) as StopsDifference
from (
select 1.4, 2 union all
select 5.6, 16 union all
select 11, 3.5
) u (FNumber1, FNumber2);
returns these results:
FNumber1 FNumber2 StopsDifference
-------- -------- ---------------
1.4 2.0 1
5.6 16.0 3
11.0 3.5 -3.3
Lens Aperture Adjustment for Zoom Lenses
Calculating the number of stops between two F-numbers is useful for determining the actual aperture on a zoom lens with variable maximum aperture.
As I used the Nikkor 35-70mm f/3.5-4.8 zoom lens that came with my Nikon FM10, I began wondering what aperture I was actually shooting at when I set it to focal lengths greater than 35mm. Like many other zoom lenses, the one that Nikon included with this inexpensive consumer-grade film camera has markings that attempt to signal to its user what’s going on.
When the focal length is set to 35mm (indicated in green on the left side of the zoom ring), the set aperture lines up with a green dot just above the aperture ring. But when the lens focal length is set to 70mm (indicated in yellow on the right side of the zoom ring), it’s a bit ambiguous what the actual aperture is. The yellow dot to the left of the green one helps give an approximate idea, but I’m left guessing even more when I have the lens set to 50mm. I wanted to do better.
When I make an exposure with this lens, I’ll record the focal length I shot at and the aperture setting as it lines up with the green dot. After I enter my exposure metadata into my database, I let my programming logic calculate the actual aperture.
In my database, I have a parent table representing a lens and a child table that contains zoom lens focal length markings:
create table Lens
(
LensID int not null constraint PK_Lens primary key,
Model nvarchar(255) not null constraint AK_Lens_Model unique,
PrimeFocalLength smallint null,
PrimeFocalLengthMaxAperture float null,
ZoomMinFocalLength smallint null,
ZoomMinFocalLengthMaxAperture float null,
ZoomMaxFocalLength smallint null,
ZoomMaxFocalLengthMaxAperture float null
);
create table ZoomLensFocalLengthMarking
(
LensID int not null constraint FK_ZLFLM foreign key references Lens (LensID),
FocalLength smallint not null,
constraint PK_ZoomLensFocalLengthMarking primary key (LensID, FocalLength)
);
go
My Nikkor 35-70mm f/3.5-4.8 zoom lens is represented with the following data:
insert into Lens
(
LensID,
Model,
ZoomMinFocalLength,
ZoomMinFocalLengthMaxAperture,
ZoomMaxFocalLength,
ZoomMaxFocalLengthMaxAperture
)
values
(2, 'Nikkor 35-70mm f/3.5-4.8 Zoom', 35, 3.5, 70, 4.8);
insert into ZoomLensFocalLengthMarking
(
LensID,
FocalLength
)
values
(2, 35),
(2, 50),
(2, 70);
go
Using my T-SQL function entitled dbo.FNumberStopsDifference, which I describe above, a T-SQL view named dbo.ZoomLensApertureAdjustment calculates the number of stops that the lens slows down to when its set to 50mm. Thanks to the markings on the front of the lens, I know the maximum aperture range: f/3.5 at 35mm to f/4.8 at 70mm. Along with calculating the number of stops between these two F-numbers, my T-SQL view also adjusts this difference according to the extent to which focal length is set between the lens’s minimum and maximum focal length:
create view dbo.ZoomLensApertureAdjustment
as
with l as
(
select a.LensID,
minmax.ZoomMinFocalLength,
minmax.ZoomMinFocalLengthMaxAperture,
minmax.ZoomMaxFocalLength,
minmax.ZoomMaxFocalLengthMaxAperture,
a.FocalLength
from Lens minmax
inner join ZoomLensFocalLengthMarking a
on minmax.LensID = a.LensID
where a.FocalLength > minmax.ZoomMinFocalLength
and a.FocalLength < minmax.ZoomMaxFocalLength
and minmax.ZoomMinFocalLengthMaxAperture is not null
and minmax.ZoomMaxFocalLengthMaxAperture is not null
)
select LensID,
ZoomMinFocalLength as FocalLength,
cast(0 as float) as StopsIncrease
from l
union --> distinct
select LensID,
FocalLength as FocalLength,
dbo.FNumberStopsDifference(ZoomMinFocalLengthMaxAperture,
ZoomMaxFocalLengthMaxAperture) *
(
cast(FocalLength - ZoomMinFocalLength as float) /
cast(ZoomMaxFocalLength - ZoomMinFocalLength as float)
)
from l
union --> distinct
select LensID,
ZoomMaxFocalLength as FocalLength,
dbo.FNumberStopsDifference(ZoomMinFocalLengthMaxAperture,
ZoomMaxFocalLengthMaxAperture)
from l;
go
Using f/3.5 as its starting point, this query:
select FocalLength,
StopsIncrease,
round(dbo.FNumberAddStops(
3.5,
StopsIncrease),
1) as FNumberNominalAdjusted
from ZoomLensApertureAdjustment
where LensID = 2
order by FocalLength;
returns the three actual apertures that my Nikkor 35-70mm f/3.5-4.8 zoom lens shoots at:
FocalLength StopsIncrease FNumberNominalAdjusted
----------- ----------------- ----------------------
35 0 3.5
50 0.390582414665305 4
70 0.911358967552379 4.8
Number of Stops Between Two Shutter Speeds
Comparing the number of stops between two shutter speeds and two ASA/ISO speeds is somewhat more straightforward. Let’s start with shutter speed.
The mathematical formula for determining how many stops are between two shutter speeds is:
log2(T1) - log2(T2)
where T1 and T2 are the two shutter speeds being compared.
I used this photo.stackexchange.com discussion thread for help on figuring this out.
The following T-SQL function named dbo.ExposureTimeSecondsStopsDifference returns the number of stops between two shutter speeds:
create function dbo.ExposureTimeSecondsStopsDifference
(
@ExposureTimeSeconds1 float,
@ExposureTimeSeconds2 float
)
returns float
as
begin
return (
log(@ExposureTimeSeconds1, 2) - log(@ExposureTimeSeconds2, 2)
);
end
go
This query:
select ExposureTimeSeconds1,
ExposureTimeSeconds2,
round(dbo.ExposureTimeSecondsStopsDifference(
ExposureTimeSeconds1,
ExposureTimeSeconds2),v 1) as StopsDifference
from (
select 1./250, 1./60 union all
select 1./500, 1./1000 union all
select 1./30, 1./80
) u (ExposureTimeSeconds1, ExposureTimeSeconds2);
returns these results:
ExposureTimeSeconds1 ExposureTimeSeconds2 StopsDifference
-------------------- -------------------- ---------------
0.004000 0.016666 -2.1
0.002000 0.001000 1
0.033333 0.012500 1.4
Number of Stops Between Two ASA/ISO Speeds
Similar to shutter speed, the mathematical formula for determining how many stops are between two ASA/ISO speeds is:
log2(S1) - log2(S2)
where S1 and S2 are the two ASA/ISO speeds being compared.
As above, I used this photo.stackexchange.com discussion thread for help on figuring this out.
The following T-SQL function named dbo.ISOSpeedStopsDifference returns the number of stops between two ASA/ISO speeds:
create function dbo.ISOSpeedStopsDifference
(
@ISOSpeed1 float,
@ISOSpeed2 float
)
returns float
as
begin
return (
log(@ISOSpeed1, 2) - log(@ISOSpeed2, 2)
);
end
go
This query:
select ISOSpeed1,
ISOSpeed2,
round(dbo.ISOSpeedStopsDifference(
ISOSpeed1,
ISOSpeed2),
1) as StopsDifference
from (
select 100, 800 union all
select 400, 200 union all
select 1600, 125
) u (ISOSpeed1, ISOSpeed2);
returns these results:
ISOSpeed1 ISOSpeed2 StopsDifference
--------- --------- ---------------
100 800 -3
400 200 1
1600 125 3.7
Exposure Value (EV)
As the Wikipedia article on EV points out, German shutter manufacturer Friedrich Deckel came up with the idea of EV in the 1950s. In order to simplify exposure settings, he combined exposure time and aperture into a single number. Some camera bodies from the era have EV numbers indicated on them. But the idea never really caught on, and EV numbers disappeared from camera bodies in short order. Still, the logic behind EV is very useful.
The calculation for EV is:
EV = log2(N2 / T)
where N represents the F-number and T represents shutter speed in seconds.
One can also incorporate the third corner of the exposure triangle into this formula. Assuming that ASA/ISO 100 is stop number zero, the calculation is:
EV = log2(N2 * 100 / (T * S))
where N represents the F-number, T represents shutter speed in seconds, and S represents ASA/ISO speed.
My thanks goes to the Wikipedia article on EV and the exposure calculator at omnicalculator.com for insight on how to make these two calculations.
My T-SQL function that expresses the latter of these two calculations is dbo.EV, which I coded as follows:
create function dbo.EV
(
@FNumber float,
@ExposureTimeSeconds float,
@ISOSpeed float
)
returns float
as
begin
return (
log(square(@FNumber) * 100 / (@ExposureTimeSeconds * @ISOSpeed), 2)
);
end
go
Using lookup tables for aperture, exposure time, and ASA/ISO values (refer to this sample database script for details), I can join all three together on stop number:
select
round(a.StopNumber, 2) as FNbrStopNbr,
a.FNumberNominal as FNbr,
round(t.StopNumber, 2) as ExpTimeStopNbr,
t.FriendlyDescription as ExpTime,
round(i.StopNumber, 2) as ISOStopNbr,
i.ISOSpeedNominal as ISO,
round(dbo.EV(a.FNumberPrecise,
t.ExposureTimeSecondsPrecise,
i.ISOSpeedPrecise), 2) as EV
from Aperture a
inner join ExposureTime t
on a.StopNumber = t.StopNumber * -1
inner join ISO i
on a.StopNumber = i.StopNumber
where t.FullStop = 1
order by EV;
Note how the exposure speed stop number sign is reversed in the FROM clause join condition.
The above query returns these results:
FNbrStopNbr FNbr ExpTimeStopNbr ExpTime ISOStopNbr ISO EV
----------- ---- -------------- ------- ---------- ----- --
-2 0.5 2 4" -2 25 -2
-1 0.7 1 2" -1 50 -1
0 1 0 1" 0 100 0
1 1.4 -1 0"5 1 200 1
2 2 -2 1/4 2 400 2
3 2.8 -3 1/8 3 800 3
4 4 -4 1/15 4 1600 4
5 5.6 -5 1/30 5 3200 5
6 8 -6 1/60 6 6400 6
7 11 -7 1/125 7 12800 7
8 16 -8 1/250 8 25600 8
This is a great demonstration of the wonderful harmony that rests in the math behind the exposure triangle.
Filter Factor
Many lens filters reduce the amount of light that ultimately passes to the recording medium. The extent to which a filter does this is specified as its filter factor. Taking this into account when making an exposure is important particularly when a photographer is using a camera without a built-in light meter.
For more information, see the Wikipedia article on filter factor.
The mathematical formula for translating filter factor into the number of stops that a filter reduces light throughput is simply:
log2(FF)
where FF is the filter factor specified for the filter by the manufacturer.
This query:
select 'Nikon 85B orange filter' as FilterModel,
1.6 as FilterFactor,
round(log(1.6, 2), 2) as StopsSlower;
returns these results:
FilterModel FilterFactor StopsSlower
----------------------- ------------ -----------
Nikon 85B orange filter 1.6 0.68
I used this logic to create a computed column named FilterFactorLightReductionStops in a table that holds lens filter data.
Bringing It All Together
Most of what I have discussed in this article concerns either a lens’s focal length or how an exposure is made. In sum, I can represent all of this with the following query against a table named Photograph (refer to this sample database script for details):
select
round(cast(coalesce(l.PrimeFocalLength,
p.ZoomLensFocalLength) as float) *
c.CropFactor,
0) as FL35mmEquiv,
f.Model as LensFilter,
p.FNumberNominal as FNbr,
(
--find the nearest match
select top 1 t.FriendlyDescription
from ExposureTime t
order by abs(p.ExposureTimeSecondsNominal -
t.ExposureTimeSecondsNominal)
) as ExpTime,
p.ISOSpeedNominal as ISO,
round(dbo.EV(
(
--find the nearest match
select top 1 a.FNumberPrecise
from Aperture a
order by abs(coalesce(dbo.FNumberAddStops(p.FNumberNominal,
j.StopsIncrease),
p.FNumberNominal) - a.FNumberPrecise)
),
(
--find the nearest match
select top 1 t.ExposureTimeSecondsPrecise
from ExposureTime t
order by abs(p.ExposureTimeSecondsNominal -
t.ExposureTimeSecondsPrecise)
),
(
--find the nearest match
select top 1 i.ISOSpeedPrecise
from ISO i
order by abs(p.ISOSpeedNominal - i.ISOSpeedPrecise)
)) + coalesce(f.FilterFactorLightReductionStops, 0),
1) as EV
from Photograph p
inner join Camera c
on p.CameraID = c.CameraID
inner join Lens l
on p.LensID = l.LensID
left outer join LensFilter f
on p.LensFilterID = f.LensFilterID
left outer join ZoomLensApertureAdjustment j
on p.LensID = j.LensID
and p.ZoomLensFocalLength = j.FocalLength;
This query returns these results:
FL35mmEquiv LensFilter FNbr ExpTime ISO EV
----------- ----------------------- ---- ------- ---- ----
50 NULL 8 1/125 100 13
50 NULL 16 1/125 100 15
50 NULL 5.6 1/60 100 11
50 NULL 16 1/250 400 14
50 NULL 11 1/250 200 14
50 Nikon 85B orange filter 8 1/500 400 13.7
50 Nikon 85B orange filter 8 1/1000 400 14.7
50 Nikon 85B orange filter 8 1/2000 400 15.7
50 NULL 11 1/500 400 14.3
35 NULL 8 1/30 400 9
70 NULL 5.6 1/500 400 13
35 NULL 3.5 1/250 400 9.7
50 NULL 11 1/125 400 12.3
39 NULL 9 1/320 100 14.7
52 NULL 5 1/30 6400 3.7
56 NULL 8 1/250 200 13
73 NULL 10 1/200 100 14.3
56 NULL 5.6 1/80 100 11.3
There is surely far more math that relates with photography. What I’ve described above is just the tip of the iceberg.