Docsity

Understanding Camera Lens Focal Length and Depth Compression - Prof. Mong-Ying A. Hsieh, Assignments of Robotics

Toggle sidebar
bg1
MEM: Intro to Robotics
Assignment 3I
Due: Wednesday 10/15 11:59 EST
1. Basic Optics You are shopping for a new lens for your Canon D30 digital camera and there
are lots of lens options at the store. Your Canon D30 has a sensor size of 21.8 x 14.5mm, but
all the lenses on the market have focal length specifications that are valid only for 35 mm film
cameras. If a lens with a 50 mm focal length (we call this a 50 mm lens) designed for a 35 mm
film is actually used in a camera with a different sensor size (i.e. not 35 mm), this will impact the
field of view and therefore the actual focal length will no longer be 50 mm. Luckily you’re taking
E28/CS82, and recall that the field of view φis related to the lens focal length fand camera sensor
or film size dby
φ= tan−1d
2f.(1)
The aim of this problem is find a simple conversion so that you would be able to compute what
the actual focal length will be in your new camera before purchasing a lens which was designed for
a different film/sensor size.
Let’s fix some notation; unless otherwise mentioned, this notation is consistent through all parts
of the problem:
•dfilm : the width of the film that a lens is designed to work for (e.g. 35 mm)
•ddigital: the width of the digital sensor in your camera (e.g. 21.8mm)
•fe: the effective focal length of the combination of your digital camera and the lens you’d like
to buy
(a) Using (1), write an expression for the field of view φin terms of the focal length fof the lens
youd like to buy, and the sensor width dfilm . Using your newfound expression, what is the
field of view φif the focal length fis 50 mm and ddigital = 21.8mm?
(b) Now that you have computed the field of view φin terms of ddigital, once again use (1) to find
an expression for fe. Assume the field of view φis what you obtained from (a) and replace
Figure 1: Diagram showing the field of view φwith respect to the focal length fand sensor size d.
1
pf3
pf4
pf5

Partial preview of the text

Download Understanding Camera Lens Focal Length and Depth Compression - Prof. Mong-Ying A. Hsieh and more Assignments Robotics in PDF only on Docsity!

MEM: Intro to Robotics

Assignment 3I

Due: Wednesday 10/15 11:59 EST

  1. Basic Optics You are shopping for a new lens for your Canon D30 digital camera and there are lots of lens options at the store. Your Canon D30 has a sensor size of 21.8 x 14. 5 mm, but all the lenses on the market have focal length specifications that are valid only for 35 mm film cameras. If a lens with a 50 mm focal length (we call this a 50 mm lens) designed for a 35 mm film is actually used in a camera with a different sensor size (i.e. not 35 mm), this will impact the field of view and therefore the actual focal length will no longer be 50 mm. Luckily you’re taking E28/CS82, and recall that the field of view φ is related to the lens focal length f and camera sensor or film size d by

φ = tan−^1

d 2 f

The aim of this problem is find a simple conversion so that you would be able to compute what the actual focal length will be in your new camera before purchasing a lens which was designed for a different film/sensor size. Let’s fix some notation; unless otherwise mentioned, this notation is consistent through all parts of the problem:

  • df ilm: the width of the film that a lens is designed to work for (e.g. 35 mm)
  • ddigital: the width of the digital sensor in your camera (e.g. 21. 8 mm)
  • fe: the effective focal length of the combination of your digital camera and the lens you’d like to buy

(a) Using (1), write an expression for the field of view φ in terms of the focal length f of the lens youd like to buy, and the sensor width df ilm. Using your newfound expression, what is the field of view φ if the focal length f is 50 mm and ddigital = 21. 8 mm?

(b) Now that you have computed the field of view φ in terms of ddigital, once again use (1) to find an expression for fe. Assume the field of view φ is what you obtained from (a) and replace

Figure 1: Diagram showing the field of view φ with respect to the focal length f and sensor size d.

f with fe. Simplify your answer so that fe in solely expressed in terms of f , df ilm, and ddigital.

(c) From the equation found in part b), compute what the effective focal length would be if you were to use the 50 mm lens in your ddigital = 21. 8 mm camera. What would the effective focal length be in the case of 35 or 80 mm lenses?

(d) Finally, repeat part c) for two more digital cameras: the Nikon Coolpix 5000 with a sensor size of 8.8 x 6. 6 mm and the Kodak 760 with a sensor size of 27.8 x 18.5 mm. For each lens and camera, write the corresponding effective focal length in the table below:

50 mm 50 mm 80 mm

Canon D

Nikon Coolpix 5000

Kodak 760

  1. Depth Compression We have seen in class that by increasing the focal length, the field of view becomes narrower and one obtains, as shown in Figure , a zooming in effect on the objects in the photographed scene. As the focal length increases, objects that are further away will actually increase in size faster than closer objects. This creates a ‘depth compression’ effect; the further away objects appear closer than they actually are as the focal length increases. Figure shows a simple scenario. Two objects are placed at distances D 1 and D 2 from the image plane (note that the distance is not computed with respect to the center of projection COP , but rather the image plane). The figure shows two different choices of COP : COP ′^ and COP ′′, and in each case, the projections of object 1 onto the image plane are traced out. When COP ′^ is used, the corresponding focal length will be f ′. On the image plane the object appears as approximately half the size of the plane. When the center of projection is changed to COP ′′^ and, correspondingly the new focal length is now f ′′, the projection of object 1 becomes much smaller. Hence, by increasing the focal length from f ′′^ to f ′^ the object appears bigger in the final image. The purpose of this exercise is to better understand the basics geometry of how 3D objects are projected onto the image plane and how the ‘depth compression’ effect arises. Using the Canon D30 camera you want to create special effects while taking souvenir pictures of the Eiffel tower. The camera has a 21.8 x 14.5 mm sensor (use the width d = 21.8 mm for your computations) and a resolution of 2160 x 1440 pixels. The height of the Eiffel tour is h 2 = 324 m, while the height of an average person is h 1 = 1.70 m. Assume the camera is positioned on the ground and the setup is as shown in Figure 3. Let D 1 and D 2 denote the distances of the person and the tower from the projection plane. As an example, let the tower be at D 2 = 1500 m from the image plane. If we want the tower to appear half the size of the image, the focal length f can be found by looking at similar triangles:

h 2 D 2 + f

d/ 2 f

1500 + f

f

which yields a focal length f = 50.5 mm. In this case, the tower will appear as half the image height, or 1440/2 = 720 pixels tall. Note that in order for this to be true it would be incorrect to simply solve for f in (1) by taking only half the field of view, as the height of the object does not correspond to the arclength of the circular sector of angle ϕ.

Figure 4: Standard camera geomtry.

(a) Given the same settings as above, verify that the size of each pixel corresponds to 10. 1 μm. If the focal length f is given to be 50 mm and the distance D 2 from the tower to the sensor is 1500 m, what would be the resulting height of the tower in pixels?

(b) If the focal length f is given to be 50 mm at what distance D 2 should the camera be positioned in order for the Eiffel tower to be completely within the field of view? At what distance D 1 should the person stand in order to appear of the same height as the tower in the final image?

For the last two parts, fix the position of the camera with respect to the Eiffel tower (fix f + D 2 ), as in the previous part, and denote the distance D from the sensor to the tower Dt.

(c) What would the new focal length f ′^ need to be in order to have only half of the tower in the field of view (and hence make it twice as big)?

(d) At what new distance D 1 should the person stand in order to still fill the field of view completely (so that now the tower would look closer to the person)?

  1. Camera Geometry Recall the standard projection equations that relate a point (x, y, z) in R^3 to its projection in the image plane:

(x, y, z) −→ (−d

x z , −d

y z ) = (xp, yp) (3)

The standard projection is shown in Figure 4. Note that the camera points in the negative z direction so that a point on the projection plane is given by (xp, yp, −d) where d is now the focal length. This simple camera projection equation results in several non-trivial facts. After seeing the effect that focal length had on depth compression, we now look at how the camera position affects how the vanishing lines appear in the 2D image. Recall the line on the floor shown in the lecture slides. The line can be represented by intersecting the floor plane given by y = −1 and the plane given by x = az + b. At the horizon (when z → −∞) a point on this line projects to (a, 0) on the image plane. In this problem, we will study how the projection is affected when the camera is rotated by an angle θ about the x-axis (and the y-axis, too).

(a) If we tilt the camera by an angle θ about the x-axis, we rotate the y-z plane. The 3x3 matrix

representing this rotation is given by:

Rx =

0 cos θ − sin θ 0 sin θ cos θ

What would the new coordinates (x′, y′, z′) of a point (x, y, z) be after this rotation is applied?

(b) If for simplicity we rewrite our line in a parametric form with respect to a single variable t, the initial line can be expressed as follows:

x = at + b y = − 1 (5) z = t

This means that every point on the line can be mapped to a unique value of −∞ ≤ t ≤ ∞ (which makes sense, since a line is a 1D structure). What would be x′, y′, z′^ be for the line in terms of the rotated coordinate system?

(c) Rewriting (3) in terms of the new coordinates yields:

(x′, y′, z′) −→ (−d x′ z′^

, −d y′ z′^

) = (x′ p, y′ p) (6)

What will x′ p and y′ p be in terms of the new coordinates found in part (b)?

(d) To find where a point on the horizon will project to in the image, let t → −∞. What will be the image coordinates of this point?

(e) Finally, what would happen if after rotating the camera about the x-axis, we also rotate the camera about the y-axis? (Hint: after computing x′, y′, z′^ in part (a) multiply the latter by a new rotation matrix Ry and then repeat parts (b)-(d) to find the new projected point).

  1. Connected Components For this assignment you will implement the Connected-Component Labeling Algorithm discussed in class. In A3IMatlab.zip you will find 3 Matlab m-files and 6 PNG images. First, ccl MEM455.m provides a basic code structure for you. Your code should go in the section indicated by the comment YOUR CODE HERE. You may need to change the cutoff value when you convert the images to a binary image since your results will differ for different values of cutoff. Additionally, the way ccl MEM455.m is set up, it will segement out the lighter regions of the image rather than the darker ones. This is relevant when you use a color image as your input. I suggest you being with the image named bwImage1.png since this is the simplest image of all six. Once you have debugged your code and it is working, you can try it on the rest of the images. Once your code is working, pick your favorite image and try your code on it.

What to turn in for Problem 4. Submit your version of the ccl MEM455.m code. I will run your code on a different image to see whether it works or not. In your write-up, make sure you include all the output images. Remember, your PDF files must be no larger than 5MBs.