Choosing a lens for your 100% inspection system
It's one of the key elements of any vision system. It determines the physical size most machine vision solutions. It can determine the quality of the inspection systems results. It can make or break an application and we have found that few people understand the fundamentals. We will look at the basics of lens selection and explain the significance of each tolerance. We will examine the following:
- How the aperture works.
- Depth of field
- Focal length
How does the aperture of a lens work?
When light passes through a camera's lens, it must pass through an opening called an "Aperture". The aperture, which is an opening in the lens diaphragm, is like an adjustable hole, that lets in more light the more it is open, less light the more it is closed. In essence the aperture is just like the pupil in the human eye. You can control the amount of light passing through onto the CCD in the camera, by setting the "Aperture Opening". The image below on the left shows the aperture of a lens fully opened, allowing maximum light into the camera. The image to the right below shows the aperture almost closed, allowing very little light into the camera.
The "Aperture Opening", also referred to as an F-Stop, this controls the amount of light that passes through the lens. It does so by closing up to restrict light, and opening up to let it through. A Lower F-stop numbers indicate MORE LIGHT. Higher F-stop numbers indicate LESS LIGHT.
Most diaphragms are made from thin metal blades which overlap. By rotating an aperture control ring (f-stop adjustment dial) fitted around the barrel of the lens, the blades move smoothly towards the centre of the lens or away from it, resulting in the aperture being reduced or enlarged in diameter.
From the figure above, it can be seen that the size of the aperture (the degree to which the lens is said to be "open") is represented by numerically identified f-stops, engraved on the F-stop adjustment dial and gauge. The lens has eight f-stops (1.8, 2.8, 4, 5.6, 8, 11, 16, and 22). It seems contradictory but is important to remember that a larger F-stop number designates a smaller lens opening, and vice-versa. In the figure below for example, an aperture of F16 has a very small lens opening, whereas an aperture of F2.8 is a relatively large opening, and will let a great deal more light pass through the lens.
You are said to “open” the lens when you go from a smaller aperture to a larger one, and a lens is“wide open” or at "full aperture" when its maximum aperture is selected. When you select any smaller aperture, you are said to be “stopping down” the lens, so a change in aperture from F5.6 to f11 involves stopping down two stops - i.e. from F5.6 through F8 to F11 (it seems strange to be stopping down with f- numbers that go up, but that’s the way it is). A lens that is fully stopped down is at its minimum aperture.
Relationship between aperture and brightness
F-stop numbers are based on a standard geometric scale. Each F-stop is precisely engineered to let in twice as much light as the next smaller F-stop, and half as much light as the next larger one. F8 therefore allows twice as much light through the lens as F11 and half as much as F5.6. This of course also means that F8 allows the passage of four times as much light as F16 which is two stops smaller. Using F5.6 as a standard, the amount of light reaching the sensor will change according to F-stop as indicated below:
What's a half stop?
The lens used in the 100% inspection system will function with the aperture set between two F-stop numbers, and then your aperture is neither one nor the other, but becomes a setting between the two (there will be no discernible click when you set your aperture between two marked F-stops). This is sometimes referred to as a half-stop, however there is no way of measuring exactly halfway between two F-stops. You will find the larger the range of F-stops, the more expensive the lens is. As a rule of thumb, I always design the lighting to allow a lens sit at least 2 stops from maximum aperture. The ability to change the lens’ aperture settings is particularly important because the size of the lens opening governs the ‘depth of field’.
What is Depth of Field and how does it affect my vision system?
When you focus the camera lens on a subject to get a sharp image, other objects nearer to the lens, and further away from it, do not appear equally sharp. This decline in sharpness is gradual and progressive. There is, therefore, an area of apparent focus – ‘zone of sharpness’, where the blur is too small to be noticed and will therefore pass to the viewer as sharp, that exists in front of, and behind, the lens. Depth of field is the technical term used to describe this 'zone of sharpness' between nearest and furthest of a subject in focus, i.e. the distance of sharp focus in front and behind the subject on which the lens is focused.
The figures below, while exaggerated, may help to explain depth of field in relation to the line scan inspection of a web pattern. It is desirable that the depth of field should fully cover the part of the web being inspected. Then all points on the web will fall within the depth of field, thereby be in focus, and produce a sharp image. See below how the depth of field is affected by the aperture setting:
Let's look at three independent facts
- The smaller the aperture, the deeper the depth of field (the other two factors remaining the same) and vice versa. For example, if the lens focal length and the shooting distance stay the same, the depth of field is much deeper at F/16 than at F/1.4.
- The shorter the lens focal length, the deeper the depth of field (the other two factors remaining the same) and vice versa. For example, comparing a 28mm lens with a 50mm lens at the same aperture and shooting distance, depth of field is deeper with the 28mm lens.
- The greater the shooting distance, the deeper the depth of field (the other two factors remaining the same) and vice versa. For example, if the subject is imaged from 0.5m and then from 1m away, the zone of sharpness in the foreground and background is greater at 1m.
Depth of focus versus depth of field
When the camera lens is focused on an object there is one position where the image is sharpest. The sharpness falls off as the CCD is moved away from this position of exact focus. There is a certain range of focusing movement within which it is not possible for the human eye to detect a difference between what is actually sharp and a very slightly blurred, or soft image. This is called depth of focus. Not to be confused with depth of field. The difference being that depth of field is the range that the subject can be moved and still be in apparent focus. The depth of focus being the range that the CCD can be moved within the CCD plane and still appear sharp. Depth of focus increases as the aperture gets smaller (same as depth of field). However, as the subject is brought nearer to the camera, or you use a longer focal length lens, the depth of focus increases. This is the exact opposite of what happens with depth of field.
What is focal length and does it matter?
Very simply, it is the distance from the lens to the sensor, when focused on a subject at infinity. In other words, focal length equals image distance for a far subject. To focus on something closer than infinity, the lens is moved farther away from the lens. This is why most lenses get longer when you turn the focusing ring.
The distances follow this formula:
This means a 400mm lens should be 400mm long. If you get out your ruler and measure it, you will find it is less than 400mm. That is because a camera lens really has many individual glass lenses inside, and this makes it behave as if it is longer than it really is. This is called "telephoto."
As you can see the focal length of a lens also determines its cone of view. This has an effect on distortion. When doing web inspection, it is important to reduce the effect of distortion on objects on the outer edges of the field of view, else it can affect detection and classification. It is also important as the focal length, along with the resolution or magnification will affect the working distance. For example, a system with a magnification of say 10, (100um pixel at web and 10um at camera sensor) will have an approximately working distance of 500mm for a 50mm lens and 1050mm for a 105mm lens. This has a knock on effect to the illumination required as the further away, the more light required.
Choosing a lens is not just about price. The lens will have knock on effects to the mechanical structure, the type of light used and the quality of the inspection. The advice is choose carefully. If you wish to learn more, OneBoxVision has developed a complete library of information with useful white papers, click the link below to access.