# depth of field and f-stop

I have a thorlabs DCC1545M camera. https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=4024&pn=DCC1545M

e.g. it has a 1/2 inch format, a sensor size of 6.66mm*5.32mm, with 1280*1024 resolution.

I want a close up of the human eye when the eye is between 80cm and 120cm from the camera. I want the pupil in the eye image to have a minimum diameter of 25 pixels when the real-world pupil diameter is 3mm. I used the pin-hole camera model to estimate that at 120cm distance, I would need a lens with focal length of 52mm.

However, I use the following depth of field calculator: http://www.dofmaster.com/dofjs.html

when I set focal length to 52 and subject distance to 100cm, I need to select an f-stop of 32 to get the approximate depth of field I wanted: it gives 37.1cm depth of field.

when i look for lenses with focal length around 50mm, they usually have much lower f-stop numbers which would give a very small depth of field...

am i on the right track so should look for a 52mm lens with f32 or am i missing something important.

I am a computer programmer and have little experience with lenses. Any pointers would be welcome....

I have a thorlabs DCC1545M camera. https://www.thorlabs.com/newgrouppage9.cfm?objectgroup_id=4024&pn=DCC1545M

e.g. it has a 1/2 inch format, a sensor size of 6.66mm*5.32mm, with 1280*1024 resolution.

I want a close up of the human eye when the eye is between 80cm and 120cm from the camera. I want the pupil in the eye image to have a minimum diameter of 25 pixels when the real-world pupil diameter is 3mm. I used the pin-hole camera model to estimate that at 120cm distance, I would need a lens with focal length of 52mm.

However, I use the following depth of field calculator: http://www.dofmaster.com/dofjs.html

when I set focal length to 52 and subject distance to 100cm, I need to select an f-stop of 32 to get the approximate depth of field I wanted: it gives 37.1cm depth of field.

when i look for lenses with focal length around 50mm, they usually have much lower f-stop numbers which would give a very small depth of field...

am i on the right track so should look for a 52mm lens with f32 or am i missing something important.

I am a computer programmer and have little experience with lenses. Any pointers would be welcome....

## EDIT

Thank you for your responses. I am working my way through the content.

I want to use a fixed focal length lens. In fact, I would like the aperture size and focus to be fixed (the camera is used by software to capture images and I don't want to manually change camera/lens properties). The idea is to ensure the pupil (3mm in diameter) is 25 pixels or more and is in-focus (sharp) as the pupil moves between 80cm and 120cm along the camera's line of sight.

I calculated the required focal length for a 25 pixel pupil at 120cm distance. This would mean that as the head moved forward the pupil would be greater than 25 pixels.

With a depth of field of 40cm (e.g. 80cm to 120cm pupil movement), I seem to need a large f-stop value. Actually, the need for illumination and long exposure times is problematic for me.

I envisaged using a manual focus lens. However, I would not want to change the focus on the lens while taking the images e.g. as the head moves. So what I am really looking for is a lens with fixed focal length, fixed aperture and fixed focus. However, I am confused now as to the relationship between f-stop and focus for a fixed focal length lens. Suppose the lens is 52mm (provided I calculated it correctly), if I want a sharp image of the pupil as it moves between 80cm and 120cm then can this be done with fixed focus and what is the impact of f-stop?

I am sorry if I seem confused.

I would just like to run my focal length calculations by you. If the focal length of the lens is F then we can define:

f_x=(F*HORIZONTAL_PIXELS)/(SENSOR_WIDTH )

If we substitute the properties of the Thorlabs DCC1545M camera we get

f_x=(F*1280 )/6.66

now if pixel coordinates are (u,v)

u=(f_x*x)/z

suppose that we locate two points on the left and right of the pupil in the camera image where u1,v1 is the leftmost pupil pixel coordinate and u2,v2 is the rightmost pupil pixel coordinate

∆u=u_2-u_1

∆u=(f_xx_2)/z-(f_xx_1)/z

∆u=(1280*F*∆x)/(6.66*z)

We can rearrange as follows,

F=(∆u*6.66*z)/(1280*∆x)

Now as ∆u = 25 pixels and ∆x = 3mm

F = 52.03125mm

• Possible duplicate of How can I get the most possible depth of field out of close-up/macro shots? Dec 3, 2017 at 15:55
• Perhaps a different DOF Calculator with a simultaneous FOV Calculator will be more intuitive. Try dofsimulator.net/en/?x=EClBwsB2wAAIBk50AAAjgAA . - You don't want too dark an image or too slow a shutter speed.
– Rob
Dec 3, 2017 at 17:06
• I am not sure how the possible duplicate relates to my question as it seems too abstracted. Here I am looking at solving a specific problem which will require help from people with much more experience than myself. A specific example (as contained in this question) may be of benefit to general researchers (like me) who do not come from a photography background. Dec 4, 2017 at 6:48
• F in your calculations is not focal length: it's more like width of field (term invented for this comment). I thought there was something odd about your mention of the pinhole model, and now I've put my finger on it: a pinhole camera has infinite focal length. You need to use the simple lens formula to calculate with a finite focal length. Dec 4, 2017 at 10:49
• @ user3079907 I added some calculations to augment my answer -- please read and acknowledge. Dec 4, 2017 at 23:42

Depth-Of-Field calculations are daunting. We are talking about the distance before and behind the point focused upon that will have acceptable sharpness. Math models are based on the tolerable size of the circle of confusion. This is a tiny diffused point of light that comprises the optical image. I calculated this span for you using a circle diameter of 1/1000 of the focal length lens chosen. In this case, it’s 52mm. Thus the circle size I used is 0.052mm. Since the accepted circle size is 0.5mm when the image is viewed from standard reading distance, 0.052 is about 10X smaller. This will allow 10X enlargement to be deemed acceptably sharp.

Depth of field table 52mm lens focus point 120mm camera to subject:

f/32 ----- 690mm thru 4557mm

f/22 ---- 795 mm thru 2429mm

f/16 ---- 875mm thru 1897mm

f/11 ---- 955mm thru 1604mm

Let me add, depth-of-field is subjective, based on the acuity of the eyesight of the observer, the contrast of the image being examined, and the brightness of the image being viewed. The circle of confusion diameter is 3.4 minutes of arc or stated differently, a circle whose diameter is 1/1000 of the viewing distance. Using 1/1000 is deemed OK for most situations, as it roughly takes into account the degree of magnification applied to view the image. Leica, for critical purposes uses 1/1500 and Kodak uses 1/1750. Most depth of field tables are based on 1/1000 of the focal length.

Formula for DOF

P = point focused upon

Pd = distant point sharply defined

Pn = near point sharply defined

D = diameter of circle of confusion (usual 1/1000 of F)

f = f-number

F = focal length

Pn = P/ 1 + PDf/F²

Pd = P/ 1 – PDf/F²

The image sensor measures 5.32mm by 6.66mm. The pixel count is 1024 by 1280. Simple division shows that the span of a single pixel 0.0052mm. This is true for both the horizontal and vertical. If the goal is an image size spanning 25 pixels, then 0.0052 X 25 = 0.13mm. This is the minimum permissible diameter of the image of a pupil. Using the pupil size of 3mm, the magnification for this image is 3/0.13 = 23 written as -23. The negative sign indicates that this will be a reduction.

So the question is, what lens (focal length to use to obtain a -23X. Further you state the subject to camera distance is to be between 800mm thru 1200mm. The center of this image to camera span is 1000mm.

We position the camera 1000mm from the eye to be photographed. Using the 3mm pupil diameter, we trace a triangle, base 3mm, height 1000mm. The ratio of height to base is 1000/3 = 333.3

The camera lens projects a similar triangle. By similar, all angles are the same. The base of this triangle is the image of the pupil. Per above calculation, this will be 0.13mm. Now the height of this triangle is approximately the focal length of the lens. Using this ratio, the focal length will be 333.3 X 0.13 = 43.3mm.

If a 50mm lens is mounted you can obtain a similar image size by simply changing the camera to subject distance. Assuming a 50mm is used, the image triangle base is 0.13mm and the height is 50mm. The ratio is 50/0.13 = 385. To calculate lens to subject distance, the object triangle has a base of 3mm the camera to subject distance is 3 X 385 = 1155mm.

If a 45mm lens mounted, then the image triangle base is 45/0.13 = 346. The object triangle is 3 X 346 = 1038mm. This will be approximately the camera to eye distance.

Assuming you mount a 45mm lens: Set to f/5.6 using a circle of confusion of 1/000 of 45 = 0.045mm.

Point focused upon distance = 1038mm

f/5.6 aperture setting

Distant point sharply defined = 1192mm

Near point sharply defined = 919mm

Span of depth of field = 273mm

• Thank you for your answer. and for giving me a clear breakdown of the DOF calculation. I was uncertain how to obtain the CoC so thanks for explaining this. Dec 4, 2017 at 6:40
• Thanks for the update. Your focal length calculations seem to be mathematically equivalent to my own but derived differently...e.g. they seem to give the same result. Yes, I have done the depth of field calculations using your formula. Thank you for your help....it is greatly appreciated. Dec 5, 2017 at 7:46

I want a close up of the human eye when the eye is between 80cm and 120cm from the camera. I want the pupil in the eye image to have a minimum diameter of 25 pixels when the real-world pupil diameter is 3mm. I used the pin-hole camera model to estimate that at 120cm distance, I would need a lens with focal length of 52mm.

Subject size is 3mm, object size is 0.13mm, so magnification is 0.043. (Note: I somehow managed to muck up a simple division in the first edition of this answer, so all values from here on are corrected).

1/f = 1/s + 1/o, and o/s is also equal to the magnification, so 1/f = 1/s + 3/(0.13s) = 24.1/s. With subject distance of 1200mm I calculate a focal length of 50mm, so you got the right value (although as mentioned in comments, possibly not for the right reason).

when I set focal length to 52 and subject distance to 100cm, I need to select an f-stop of 32 to get the approximate depth of field I wanted: it gives 37.1cm depth of field.

I have a number of separate points to raise here.

You seem to be assuming a fixed focus. 1cm of depth of field would be enough for the visible part of the eye, so it might be worth calculating an aperture for a 5cm DoF and putting in a rudimentary auto-focus.

With the values you give (f=52mm, f/32 aperture, 100cm subject distance) the calculator you linked gives me a DoF of 11.3cm. What did you use for the circle of confusion? With the sensor specs you give, I think it should be 0.005mm (the size of one sensel).

At f/32, diffraction is a problem. I haven't done any specific calculations for your parameters, but as a rule of thumb beyond about f/11 diffraction is the limiting factor to how sharp your image will be.

Furthermore, at f/32 there is very little light getting through the aperture, so you need either a long exposure (problematic, because the eye moves fast) or a lot of light (problematic, because it might mean that the pupil isn't even 3mm in diameter).

So overall I think you should really consider whether you can use auto-focus and a wider aperture.

when i look for lenses with focal length around 50mm, they usually have much lower f-stop numbers which would give a very small depth of field...

Normally the number people care about is how wide the aperture can go, because they go narrower than most people care to use (because of the aforementioned diffraction problem) in most circumstances. However, it's certainly true that a lot of lenses won't close down beyond f/22.

All things considered, you may be best advised to try to engineer things so that you can get away with f/16.

• Thank your for your help...I have edited my question with focal length calculation. I am not sure about the difference in focal length between your formula the method I have used. Dec 4, 2017 at 6:38
• Thank you for your advice about auto focus. I am investigating this now (as you can see in my edit.) Dec 4, 2017 at 6:39