# Calculating DOF for custom optics

I was trying to get my head around the DOF for my custom optics design and sadly it seems I end up with strange situation that the Near DOF value is larger than the far one making my DOF value negative. Is that correct?

Here are the details of my system. I have camera sensor of the following dimensions (7.4mm width, 5.55mm height, 9.25mm diagonal) and of 0.8um per pixel resolution.

I am using a lens of 30 mm diameter and 50mm focal length with fstop number of 1.67

Aperture diameter used is 10mm, therefore the Fstop of the optical system is 5.

As I am not printing the images taken but save them as PNG files, therefore I assumed circle of confusion to be the diagonal of the single pixel in the output image based on the sensor size this would be 0.00113um.

My hyperfocal distance ends up being 442527.8761mm (not sure if that is correct)

My DOF near seems to be 100.0113mm My DOF far seems to be 99.9887mm

So in the end my DOF ends up being: -22.5974um. For clarity I am looking for DOF >10um for microscopy imaging.

Please let me know if that is correct or is any of my assumptions and/or calculations wrong?

• How far is the camera sensor from the subject? Nov 17, 2022 at 2:02

A few points of confusion... a 50/1.67 lens has an entrance pupil diameter of 30mm; probably defined by/equal to the diameter of the objective element. This is the relevant/effective aperture used for the calculation; not the physical diameter of the aperture opening (5mm). The entrance pupil is the optical obstruction to light transmission created by the aperture restriction, as magnified optically by the objective elements (as seen by the source/subject).

The circle of confusion (CoC) for any sensor size is calculated as *diagonal÷1500 or 9.25÷1500 in your case... about six times larger than the CoC you used. This gives you the CoC and diffraction limit for an image when viewed normally (distance ~= image diagonal); whether printed or not. And thus the depth of field (DoF) of that image when viewed in that way.

But DoF is not a fixed aspect of an image; when the image is viewed differently (from a different distance/different magnification) the DoF changes as a result. So your use of pixel level diffraction (pixel diagonal as the CoC) wouldn't necessarily be wrong; except that the diagonal of a .8um square pixel is 1.13um... (I'm assuming there is a typo). However, your calculation would result in the DoF for the image when displayed/viewed at 1500x the standard magnification (larger/closer).

*(Kodak used d÷1730 because they defined the limit of normal vision slightly differently)

• Hi, many thanks for the answer, helps a lot. I wonder however if that is normal that the near DOF value is larger than the far DOF value. Do you have any information on that aspect? Nov 16, 2022 at 15:53
• No, it is not normal for the near distance to be greater than the far distance... that makes no logical sense at all. At very short focus distances the DoF divides 50/50 in front/behind the subject/point of focus. Nov 16, 2022 at 17:22
• DoF is 50/50 at unity (1:1) magnification. At macro distances with greater than 1:1 reproduction ratios, such as with a lens like the EF-M 65mm 1-5X Macro, front DoF will be marginally larger than rear DoF, but this is an edge case. At any subject distance that results in less than 1.0X magnification, rear DoF will be larger than front DoF, but only marginally so at close focus distances. The 33/67 split that is often used as a rule of thumb occurs at subject distances much longer than the lens' focal length. Nov 17, 2022 at 1:55
• @JamesSemaj The rear edge of the rear DoF will always be greater than the focus distance. The front edge of the front DoF will always be closer than the focus distance. Nov 18, 2022 at 15:09
• D/1500 is only valid if the viewing size is 13.25x8 (for the sensor in question's 1.667:1 aspect ratio) viewed at standard distance of 20-25 cm (10"-12") or equivalent angular size to the viewer (e.g. 26.5x16 viewed from 40-50 cm). Nov 19, 2022 at 13:39