| MIL 10 User Guide
| Customize Help

Pixel and real-world units



See also
Availability
Available in MIL-Lite with restrictions

Available in MIL

When working in MIL, you can choose to use two different types of units to set information and retrieve results: pixel units or world units.

MIL-Lite does not support world units.

When working in pixel units, you are using the pixel coordinate system, where the center of the top-left pixel corresponds to (0,0), the X-axis follows the first row of pixels, and the Y-axis follows the first column of pixels. The following image shows the pixel coordinate system; the dots indicate the center of the pixels.

For MIL modules that support subpixel accuracy, it is important to keep in mind that since the center of the pixel is used as its reference position, the top-left corner of the first pixel is considered (-0.5, -0,5) and the bottom-right corner of the last pixel is (sizeX - 0.5, sizeY - 0.5).

When working in pixel units, you define angles (in degrees) with respect to the pixel coordinate system. In this case, positive angles are always interpreted to be counterclockwise with respect to the positive X-axis.

Note that the direction of rotation is inversed from the typical mathematical convention since the Y-axis is oriented downwards. To determine the angle that follows the typical mathematical convention, subtract the angle from 360 (that is, 360 - angle). For more information on the pixel coordinate system, using subpixel accuracy, and angle conventions in MIL, see the Pixel conventions and subpixel accuracy section of Chapter 19: Data buffers.

The pixel coordinate system cannot provide any information about real-world distances because a measurement between two points will be a different number of pixels depending on the camera's location. To resolve this problem, you can use world units, which relate the pixels to real distances. To work in real-world units, you must perform a camera calibration, which creates a mapping between the pixels in an image and the pixels' size and location in the real world (absolute world coordinate system, or more simply known as the absolute coordinate system). For example, you could create the following relationship between a pixel and its size and location in the real world.

The simplest type of calibration available is a uniform calibration, where each pixel in the image represents the same area in the real-world and it is assumed that no non-linear distortion is present within the image. This is only feasible if the camera is placed directly above the subject and if lens distortion can be neglected. To perform a uniform calibration, use McalUniform(). This associates a default calibration context with a specified image and saves the uniform mapping with the image. With a uniform calibration, the mapping between the pixel coordinate system and the absolute coordinate system can be a scale, a rotation, and/or translation. When calibrating with McalUniform(), you specify the scaling, rotation, and translation of the pixel coordinate system in the real world, where the operations are applied in that order.

Using three example calibrations, the following illustrations show the position of the pixel and absolute coordinate systems. Note, the pixel coordinate system is placed with respect to the absolute coordinate system because the absolute coordinate system is fixed in the world.

To handle more complex setups and various types of distortion, there exist a variety of different calibration modes, including 3D-based calibration modes. For more information on calibration, see the Uniform calibration and other calibration modes section of Chapter 25: Calibrating your camera setup.

After calibration, at least two new coordinate systems are available: the absolute (world) coordinate system, which is static once defined during calibration, and the relative (world) coordinate system, which can be moved and rotated. The relative coordinate system is the coordinate system from which coordinates are specified or returned, when working in calibrated units. Once an image is calibrated, if you perform an operation on the image, you can set information and retrieve results in real-world units; when you do so set them with respect to the relative coordinate system. This is useful, for example, if an object could appear any number of times at any location or orientation in your images, and you want to apply the same measurement or inspection process to every instance of the object. This process is known as fixturing; for more information, see the Fixturing an object with the relative coordinate system subsection of the Child buffers, regions of interest, and fixturing section later in this chapter.

Certain MIL modules natively support real-world units and automatically return results with respect to the relative world coordinate system. For a complete list of MIL modules that support this functionality, see the Working with real-world units section of Chapter 25: Calibrating your camera setup.

The following image depicts the pixel coordinate system and the absolute and relative coordinate systems.