10
Digital Image Processing
10.1 INTRODUCTION
The electronic camera/frame grabber/computer combination has made it easy to digitize,
store and manipulate images. These possibilities have made a great impact on optical
metrology in recent years. Digital image processing has evolved as a specific scientific
branch for many years. Many of the methods and techniques developed here are directly
applicable to problems in optical metrology. In this chapter we go through some of
the standard methods such as edge detection, contrast stretching, noise suppression, etc.
Besides, algorithms for solving problems specific for optical metrology are needed. Such
methods will be treated in Chapter 11.
10.2 THE FRAME GRABBER
A continuous analogue representation (the video signal) of an image cannot be conve-
niently interpreted by a computer and an alternative representation, the digital image,
must be used. It is generated by an analogue-to digital (A/D) converter, often referred
to as a ‘digitizer’, a ‘frame-store’ or a ‘frame-grabber’. With a frame grabber the digital
image can be stored into the frame memory giving the possibility of data processing and
display. The block diagram of a frame grabber module is shown in Figure 10.1. These
blocks can be divided into four main sections:
(1) the video source interface;
(2) multiplexer and input feedback LUT;
(3) frame memory;
(4) display interface.
The video source interface
The video source interface performs three main operations: (1) signal conditioning,
(2) synchronization/timing and (3) digitalization. In the signal condition circuitry the
signal is low-pass filtered with a cut-off frequency of 3–5 MHz to avoid aliasing, see
Section 5.8.3. Some frame grabbers also have programmable offset and gain.
Optical Metrology. Kjell J. G
˚
asvik
12
8
Digital
input
Vision
bus
Video input
Synchronize
Camera
synchronize
Stripper
Crystal PLL
Pixel clock
System
timing
Synchronize
monitor
Synchronize
camera
Blue
Green
Red
DAC
8
8
8
12
12
12
12
it is stored in the frame memory. The LUTs are mostly used for colouring (false colours)
of images and can also be used to draw graphics on the screen without changing the
underlying image. This can be done by protecting the lower 8 bits (the image) and draw
only in the upper 4 bits. It is therefore possible to grab a new image without destroying the
graphics. The LUT operations can be done in real time and its therefore possible to correct
images radiometrically before storing them. LUTs can not be used geometrically because
their memory is pixel organized, not space oriented. For geometrical transformations one
therefore has to make special programs. The multiplexer (MUX) in combination with the
feedback/input LUT allows some feedback operations like real-time image differencing,
low pass filtering, etc.
Frame memory
The frame memory is organized as a two-dimensional array of pixels. Depending on the
size of the memory it can store one or more frames of video information. When the
memory is a 12-bit memory, 8 bits are used for the image and 4 bit planes for generating
graphic overlay or LUT operations. In normal mode the memory acquires and displays
an image using read/modify/write cycles. The memory is XY addressed to have an easy
and fast access to single pixels.
Display interface
The frame memory transports the contents to the display interface every memory cycle.
The display interface transforms the digital 12-bit signal from the frame memory into an
analogue signal with colour information. This signal is passed to the RED, GREEN and
BLUE ports and from there to the monitor.
10.3 DIGITAL IMAGE REPRESENTATION
By means of an electronic camera and a frame grabber, an image will be represented
as a two-dimensional array of pixels, each pixel having a value g(x, y) between 0
and 255 representing the grey tone of the image in the pixel position. Most current
commercial frame grabbers have an array size of 512 × 512 pixels. Due to the way
the image is scanned, the customary XY coordinate axis convention is as indicated in
Figure 10.2.
10.4 CAMERA CALIBRATION
y
i
= my
o
(10.1b)
where m is the transversal magnification. It is well known, however, that real lenses
possesses distortion to a smaller or larger extent (Faig 1975; Shih et al. 1993). The
transfer from object to image coordinates for a distorting lens is (see Figure 10.3)
r
i
= mr
o
+ d
1
r
3
o
(10.2a)
where
r
i
=
x
2
i
+ y
2
i
,r
i
= my
o
+ d
1
y
o
(x
2
o
+ y
2
o
) (10.3b)
This results in the well-known barrel (positive d
1
) and pin-cushion (negative d
1
) distortion.
CAMERA CALIBRATION
253
y
o
x
o
f
r
o
y
i
d
) (10.4a)
y
u
= y
d
+ dy
d
(x
2
d
+ ε
2
y
2
d
) (10.4b)
where ε is the aspect ratio between the horizontal and vertical dimensions of the pixels.
The origin of the xy-coordinates is at the optical axis. When transforming to the
frame-store coordinate system XY (see Section 10.3) by the transformation
x = X − X
s
(10.5a)
y = Y − Y
s
(10.5b)
Equation (10.4) becomes
X
u
= X
− X
s
)
2
+ ε
2
(Y
d
− Y
s
)
2
] (10.6b)
where (X
s
,Y
s
) are the centre coordinates. The distortion factor d has to be calibrated by
e.g. recording a scene with known, fixed points or straight lines. The magnitude of d is
of the order of 10
−6
− 10
−8
pixels per mm
3
.
It has been common practice in the computer vision area to choose the center of
the image frame buffer as the image origin. For a 512 × 512 frame buffer that means
X
s
b
Figure 10.4 Perspective transformation
10.4.2 Perspective Transformations
Figure 10.4 shows a lens with the conjugate object- and image planes and with object and
image distances a and b respectively. A point with coordinates (x
p
,z
p
) will be imaged
(slightly out of focus) with image coordinate −x
i
, the same as for the object point (x
o
, 0).
From similar triangles we find that
x
p
=
−x
i
(z
p
+ a)
b
(10.7a)
y
p
=
−y
i
levels of the grey scale are utilized. If the highest and lowest grey value of the image are
denoted g
H
and g
L
respectively, this is achieved by the following operation:
20 40 60 80 100 120
Grey level
(a)
(b)
140 160 180 200 220 240 255
Number of pixels
20 40 60 80 100 120
Grey level
140 160 180 200 220 240 255
Number of pixels
Figure 10.5 Grey-level histogram (a) before and (b) after contrast stretching