You are on page 1of 9

Feature Extraction I

Feature extraction is the process of determining the features to be used for


learning. The description and properties of the patterns are known. How-
ever, for the classification task at hand, it is necessary to extract the features
to be used. It may involve carrying out some arithmetic operations on the
features like linear combinations of the features or finding the value of a
function.
Feature extraction and feature selection are very important problems in
machine learning. To enhance the performance of the machine learning al-
gorithm, it is necessary that the right or discriminating features are used.
Use of irrelevant features may lead to unnecessary computation. In addi-
tion, due to the peaking phenomenon, as the number of features increases, a
larger training dataset is required to get good classification accuracy. With
a fixed dataset, the accuracy increases with the number of features upto a
point, beyond which, if the number of features increases, the classification
accuracy begins to drop.

2.1 Boundary Features


In a number of image analysis applications, an important piece of infor-
mation is the shape of an object of interest within the image. Another
example in which the shape of the object is of major importance is the
Feature Extraction I
automatic character recognition in an optical character recognition (OCR)
system. Although OCR systems employing our already familiar regional
features, there is a large class of techniques that use the shape information
residing in the boundary curve of the characters. Figure 2.1a shows the char-
acter “5” as seen from the scanner of an OCR system. An appropriate image
segmentation algorithm has first been applied to separate the character from
the rest of the image. The character in Figure 2.1b is in binary form. This is
the result of the binarization phase, in which all gray levels of the character
region below a certain threshold become 0 and all above it become 1. Fig-
ure 2.1c shows the resulting boundary, after the application of a boundary
extraction algorithm on the binary version. Thus, in the last version there is
no texture of interest inside the character. What is of paramount importance
in such systems is feature invariance in geometric transformations.

Figure 2.1: Boundary representation example

Chain Code
Chain coding is among the most widely used techniques for boundary shape
description. The boundary curve is approximated via a sequence of con-
nected straight line segments of preselected direction and length. Every line
segment is coded with a specific coding number depending on its direction.
The basic idea of chain coding is to code contour directions instead of
naïve bit-by-bit binary image coding or even coordinate representations of
the contours. Chain coding is based on identifying and storing the directions
from each pixel to its neighbor pixel on each contour. Before defining this
process, it is necessary to clarify the various types of neighbors that are
associated with a given pixel in a binary image.
Boundary Features
Figure 2.2 depicts two neighborhood systems around a pixel (shaded).
To the left are depicted the 4-neighbors of the pixel, which are connected
along the horizontal and vertical directions. The set of 4-neighbors of a
pixel located at coordinate n will be denoted N4(n). To the right are the
8-neighbors of the shaded pixel in the center of the grouping. These include
the pixels connected along the diagonal directions. The set of 8-neighbors
of a pixel located at coordinate n will be denoted N8(n).

Figure 2.2: Depiction of the 4-neighbors and the 8-neighbors of a pixel (shaded)

If the initial coordinate n0 of an 8-connected contour is known, then the


rest of the contour can be represented without loss of information by the
directions along which the contour propagates, as depicted in Fig. 2.3(a).
The initial coordinate can be an endpoint, if the contour is open, or an arbi-
trary point, if the contour is closed. The contour can be reconstructed from
the directions, if the initial coordinate is known. Since there are only eight
directions that are possible, then a simple 8-neighbor direction code may be
used. The integers 0,. . . ,7 suffice for this, as shown in Fig. 2.3(b).
Feature Extraction I

Figure 2.3: Representation of a binary contour by direction codes. (a) A connected contour can be
represented exactly by an initial point and the subsequent directions; (b) only 8 direction codes are
required.

The chain codes for the example region in Figure 2.4(a) are shown in
Figure 2.5. Figure 2.5(a) shows the chain code for the four-way connectivity.
In this case, we have that the direction from the start point to the next is
south (i.e. code 2), so the first element of the chain code describing the
shape is 2. The direction from point P1 to the next, P2, is east (code 1), so
the next element of the code is 1. The next point after P2 is P3, which is
south, giving a code 2. This coding is repeated until P23, which is connected
eastwards to the starting point, so the last element (the 12th element) of the
code is 1.
The code for eight-way connectivity shown in Figure 2.5(b) is obtained
in an analogous way, but the directions are assigned according to the def-
inition in Figure 2.5(b). Notice that the length of the code is shorter for
this connectivity, given that the number of boundary points is smaller for
eight-way connectivity than it is for four-way.

Start point invariance


Clearly, this code will be different when the start point changes. Accord-
ingly, we need start point invariance. This can be achieved by considering
the elements of the code to constitute the digits in an integer. Then, we can
shift the digits cyclically (replacing the least significant digit with the most
significant one, and shifting all other digits left one place). The smallest
integer is returned as the start point invariant chain code description. This is
Boundary Features

Figure 2.4: Example of boundaries and regions

Figure 2.5: Chain codes by different connectivity.

illustrated in the fig.2.6, where the initial chain code is that from the shape
in Figure 2.5. Here, the result of the first shift is given in Figure 2.6(b);
this is equivalent to the code that would have been derived by using point
P1 as the starting point. The result of two shifts (Figure 2.6c) is the chain
code equivalent to starting at point P2, but this is not a code corresponding
16 Chapter 2. Feature Extraction I

Figure 2.6: Start point invariance in chain codes

to the minimum integer. The minimum integer code (Figure 2.6d) is the
minimum of all the possible shifts and is the chain code that would have
been derived by starting at point P11. That fact could not be used in appli-
cation since we would need to find P11; it is much easier to shift to achieve
a minimum integer.

Rotation invariance
In addition to starting point invariance, we can obtain a code that does not
change with rotation. This can be achieved by expressing the code as a
difference of chain code, since relative descriptions remove rotation depen-
dence. To use the difference of chain code instead of the code itself, count
counterclockwise the number of directions that separates two adjacent ele-
ments (First difference) as shown in fig 2.7.

Figure 2.7: First difference of chain code


Feature ExtractionII
Regional Features
In general, descriptors are some set of numbers that are produced to de-
scribe a given shape. The shape may not be entirely reconstructable from
the descriptors, but the descriptors for different shapes should be different
enough that the shapes can be discriminated.
The most common object measurements made are those that describe a
shape. Shape measurements are physical dimensional measures that charac-
terize the appearance of an object. The goal is to use the fewest necessary
measures to characterize an object adequately so that it may be unambigu-
ously classified.

Simple Shape Descriptors


Shape descriptors describe specific characteristics regarding the geometry
of a particular feature.
A few simple descriptors are:
1. Area: number of pixels contained within its boundary (The number of
pixels in the shape).
2. Perimeter: length of region’s boundary (The number of pixels in the
boundary of the shape)
3. (Non-)Compactness or (Non-)Circularity: How closely-packed the
Feature Extraction II
shape is (not): perimeter2 /area. The most compact shape is a circle
(4π). All other shapes have a compactness larger than 4π.

Area
The area is the number of pixels in a shape. While the convex area of an
object is the area of the convex hull that encloses the object as shown in the
figure below.

To compute Area of an object or shape A(S), use the following eq:


x y
A(S) = ∑ ∑ I(x, y) (3.1)
0 0
As notice that, the Area is invarint to rotate but not invarint to scale.

Perimeter
The perimeter (length) is the number of pixels in the boundary of the object.
If X1 , ..., Xn is a boundary list (Xi = (xi , yi ), the perimeter is given by:
q
P(S) = (xi − xi−1 )2 + (yi − yi−1 )2 or (3.2)

Compactness
Compactness is defined as the ratio of the area of an object to the area of a
circle with the same perimeter.
4π · area
compactness = (3.3)
( perimeter )2
Regional Features
A circle is used as it is the object with the most compact shape. The measure
takes a maximum value of 1 for a circle
Objects which have an elliptical shape, or a boundary that is irregular
rather than smooth, will decrease the measure. Using an alternate formula-
tion:
( perimeter )2
compactness = (3.4)
4π · area
The measure takes a minimum value of 1 for a circle. Objects that have
complicated, irregular boundaries have larger compactness.

3.1.2 Topological Descriptors


Topological properties are useful for global descriptions of objects in an
image. Features that do not change with elastic deformation of the object.
Topological features give a global description of a region examples:
number of holes
number of connected components
number of object edges
number of faces
number of vertices
Euler number (the difference between the number of connected components
and number of holes)

Figure 3.1: Regions with Euler number equal to 0 and −1, respectively.

You might also like