I have an optical system that forms an image at various distances (25cm range) as shown in the figure here:


What kind of optics is required to project this image onto a CCD camera but without having to adjust the focus?

  • 2
    \$\begingroup\$ In concrete terms, what are you trying to achieve? Please describe the optical system in more detail. What are its specific components? In the diagram, what do o, i, and the square represent? What do you mean by "project this image onto a CCD camera"? Do you already have the camera? \$\endgroup\$
    – xiota
    Nov 22, 2021 at 23:56
  • \$\begingroup\$ Do you want to project the image onto a sensor? Or into the front of the lens of a self-contained camera? \$\endgroup\$
    – Michael C
    Nov 23, 2021 at 6:39
  • \$\begingroup\$ Thanks xiota and Michael. The square represents telescopic relay, o and i are the locations of object and image. I would like to capture a sharp image of the object when it is at different positions. Would like to project the image onto the sensor directly but could consider intermediate optical elements in front of the self-contained camera with lens. \$\endgroup\$
    – user102753
    Nov 23, 2021 at 10:54

3 Answers 3


I believe you are asking about the relationship between the focal length of the lens, and the distances of the object and image.

It is most common to use the thin lens formula as a good approximation for this relationship:

thin lens formula

enter image description here

  • \$\begingroup\$ This says nothing about not having to adjust the focus. \$\endgroup\$ Nov 26, 2021 at 11:30
  • \$\begingroup\$ If you want your image to be in focus, you have to maintain this relationship. The question is not clear about what "adjusting the focus" actually means, so my answer is also general. You can bring the object closer or farther, or you can replace the lense, or you can move the image plane closer or father. \$\endgroup\$
    – Ophir S
    Nov 27, 2021 at 13:51

You need a focus rail.

In your diagram all three conditions exist simultaneously. If you consider the second line as being in focus at the image plane (red line); then the top condition exists as being front focused, and the bottom condition exists as being back focused (for three different objects w/in the scene).

enter image description here

If the middle condition is the fixed focus, then you need a mechanism to move the image plane and optics nearer to (top condition) or farther away from (bottom condition) the object you want in focus... this is typically called a focus rail.

Otherwise, the optics required to correct for the front focus condition are entirely different from (opposite to) the optics required to correct for the back focus condition.


(Note: Sounds like you're into physics or other non-aesthetic imaging? Maybe people at physics.stackexchange.com can be of more help.)

I don't know about any optical setups that are in focus at more than just one infinitely thin plane. So I'll offer four workarounds:

  1. Have an adjustable focusing system, either automatic or manual. (e.g. lens with a focusing mechanism or just moving the sensor back and forth)
  2. Select a lens with depth of field (DOF) large enough so that the circle of confusion (CoC) is never larger than a pixel (or even half a pixel), so the camera can't really tell the difference between in-focus and out-of-focus images.
  3. The method I usually use: Decide on the acceptable amount of blur for your application, relative to the size of the real object itself, then adjust your system accordingly.
  4. Use multiple sensors, focused at different points, so that at least one sensor will see an acceptably sharp image at every possible object point.


Option 1 is pretty self-explanatory so I won't dwell on it. Option 4 is just a variation on one of the chosen options 2 or 3 so not much to say about that either.

Options 2 and 3 require you to have a lens in front of your sensor. In other words, you're just taking photographs, but not of the object directly -- instead, you're photographing the image that your main optical system generates.

If at all possible, I'd recommend just a normal camera, with normal camera lens, instead of building your own lens assembly. Surely the people manufacturing lens for a living can produce a better result than you can.

Deciding on the acceptable amount of blur

In both options 2 and 3, you play around with the DOF until it's large enough to cover your 25 cm of range. The DOF is the range of distances which are within acceptable focus. How blurry is still acceptably focused is determined by you, using either option 2 or 3.

Option 2 is stricter: you want images to look as sharp as possible, so that you basically can't tell the difference between perfect focus and the edge of your DOF. Unfortunately, this may be unachievable in practice because it may require extremely small apertures or magnifications.

Option 3 is pragmatic: you accept the fact that perfect focus doesn't exist and instead define how much detail you need to see on your object. You define this detail in terms of object dimensions, which is easier to reason about. (For instance, on my job, if I need to see a scratch of width 0.1 mm, I may define my maximum blur diameter to be 0.05 mm.)

Parameters for manipulating DOF

You modify the DOF by tweaking the two main parameters: optical magnification and aperture diameter (which is focal distance divided by f-number). Both are trade-offs. Increasing aperture size will give you more light (faster exposure), but less DOF. Increasing magnification gives you more resolution, obviously, but also decreases DOF and FOV (field of view).

If you can choose your sensor, large DOF is usually easier to achieve with smaller pixels. They require less magnification to achieve the same resolution, which increases DOF. Less magnification means smaller focal distance, which in turn requires a smaller aperture for the same f-number and light-gathering speed, which also increases DOF.

The downside of small pixels is that they can't gather as much light (this limits their best achievable signal-to-noise ratio, but doesn't matter at all unless you have enough light to fully saturate them). Also, they require better quality lens (with more resolving power) to achieve the same image quality. If pixels are small enough, a lens which creates a sharp image at pixel level doesn't even exist.

How to do the calculations

Unfortunately, this topic is a bit too involved to explain here without knowing your exact goals and which parameters are at your disposal.

I recommend the analysis and formulas from the freely available book Depth of Field in Depth by Jeff Conrad. For option 2, use the standard DOF formulas. For option 3, use "relative blur".

To speed things up with option 3, I have some Excel spreadsheets I use in my day-to-day life. I don't have them for option 2 because I never use it.

The spreadsheets are organized by column so I can explore multiple options next to each other. I use "distances calculation.xlsx" to choose working distance, lens' focal distance and magnification at the perfectly focused plane. Then I use "depth of field calculation.xlsx" to choose the actual lens model and the required f-number for the numbers from step 1. If it doesn't work out, I go back, tweak and repeat.

If you're photographing from up-close, a simplified DOF calculation is available as a different spreadsheet tab.

If needed, ask for help in the comments.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.