Upload
others
View
15
Download
0
Embed Size (px)
Citation preview
47
CHAPTER 4
PICTURE DESCRIPTION LANGUGES AND
VECTOR CODES OF PATTERNS IN A 3X3
ARRAY OF VERTICES
4.1. Introduction
An interesting application of linguistic concepts of pattern
recognition is the Picture Description Language (PDL) which is a set of
symbol strings representing different objects in the class. The object to
be recognized in an image is a two-dimensional pattern. On the basis of
this permissible form of juxtaposition and because of the fact that each
primitive is abstracted as a directed line segment it is evident that the
structure of PDL are directed graphs and also that these structures can be
handled by string grammars. Blank primitives must be used for
generating disjoint structures. A null point primitive has identical head
and tail. The mechanics of PDL could be used to obtain the contour of a
pattern.
48
To illustrate this mechanism, consider the following PDL
grammar
G = {VN, VT, P, S} where
VN = {S, A1, A2 , A3, A4, A5, A6, A7}
VT = {R, DR, D, DL, L, UL, U, UR}
P:
S → R+A1
A1 → DR+A2
A2 → D+A3
A3 → DL+A4
A4 → L+A5
A5 → UL+A6
A6 → U+A7
A7 → UR
The result obtained by applying all the productions is
(R+(DR+(D+(DL+(L+(UL+(U+UR)))))))
The above production system creates an octagon as shown in the Figure
4.1.
Figure 4.1: Pictorial representation of a production system
49
4.2. Inference of String Grammars
Figure 4.2 shows a model of inference of string grammars. The
input {xi} is a set of sample terminal strings. The inference algorithm is a
rule based engine and the result of this inference process is a grammar G,
which is compatible with the given strings {xi }, and is a subset of L(G)
[62].
Figure 4.2: Inference engine
The inference engine approximates an object in a digital image to
a regular polygon or to a set of regular polygons, determines a syntactic
code for it and compares with that of a model code in the knowledge
base. If it is matched, then the object is recognized [23]. In the same
way, the given digital image is segmented and contoured. Then the DLC
generating algorithm is employed to get the direction and length code
DLC of the vector data. These two parts of the vector data are then
compared with the ones stored in the database. If they match, then the
shape information is decoded and then object is recognized.
50
4.3. Direction Length Code (DLC)
The connectivity between these pixels is an important concept used
in the field of object recognition. Two pixels are said to be connected, if
they are adjacent in some sense and their intensity levels satisfy a
specified criterion of similarity. If pixel p with coordinates (x,y) and
pixel q with coordinates (s,t) are pixels of object (image subset) S, a path
from p to q is a sequence of distinct pixels with coordinates
(x0, y0), (x1, y1),……….., (xn, yn)
Where (x0, y0) = (x,y) and (xn, yn) = (s,t), (xi, yi) is adjacent to (xi-1, yi-1),
1 ≤ i ≤ n, and n is the length of the path. If there a path exists from p to q
consisting of pixels in S, then p is said to be connected to q. The gap of 1
or 2 pixels, mark the presence of the next component in the same object
or the beginning of the next object which can be then found by analysing
the relationship among the components.
Figure 4.3: Pixel representation with the direction codes.
With this background, we shall see now as to how to apply the
algorithm to various image types and extract knowledge from them. Let
UR
DR
R
U UL
L
D
DL
51
(x,y) be the initial point. The algorithm continues to find the immediate
pixel connected to (x,y) in one of the 8 directions shown in Figure 4.3. In
this technique, a previously recognized direction during a scan is given
the first priority status when compared to the other preferential ones. If R
is the identified direction, then the other preferential directions are DR,
D, DL, L, UL, U, UR. The trace continues until there is no pixel
connectivity to the current point (x,y), after removing the pixels which
are already traced, thus producing a knowledge string component. By
‘knowledge’, we mean the direction code and length code of each
contour component in the image as it gives more information about the
objects present in the image.
The vector data consists of both the Direction Code (DC) and the
Length Code (LC). The direction data is a string of the elements from the
set VN that is the set of non-terminals. The string elements are separated
by a delimiter, which is denoted by the symbol �. An arbitrary square
can be represented by the vector code in the following manner:
R�DR�D�DL�L�UL�U�UR*n�n�n�n�n�n�n�n
In a vector code, the part preceding the symbol * is called direction
code and the part following the symbol * is called the length code. The
symbol n represents the length of the sides of the square.
52
4.4. Patterns over 3x3 Array of Vertices
Let us consider the simple 3X3 array of vertices in Figure 4.4. Let S
be the object present in an image f(x,y). A pixel p (5) at coordinates (x,y)
has 4 direct (horizontal and vertical 2,4,6,8) neighbours and 4 diagonal
(1,3,7,9) neighbours whose coordinates are given by (x+1,y), (x-1,y),
(x,y+1), (x,y-1), (x+1,y+1), (x+1,y-1), (x-1,y+1), (x-1,y-1).
1 •
2 •
3 •
4 •
5 •
6 •
7 •
8 •
9 •
Figure 4.4: 3X3 array of vertices
In a binary image the objects of interest in the image are represented by
the set S which consists of all points with value 1 and the complement of
S is S which consists of all points with value 0. The direct neighbours
(horizontal and vertical) of pixel p is the set ������= {6,8,4,2}
The diagonal neighbours (diagonal) of pixel p is the set
������= {9,7,1,3}
The 8-neighbours of pixel p is the set �����= ������∪ ������
Concave patterns can be constructed by removing the pixels in the
horizontal and vertical neighbours. Removing pixels 2,4,6 and 8 the total
number of concave patterns are ∑ 4Ci���� = 16
53
In the same way, the Convex patterns can be constructed by removing
the pixels in the diagonal neighbours. So, removing pixels 1,3,7 and 9
the total number of concave patterns are ∑ 4Ci���� � 16
Hybrid patterns can be constructed by removing pixels from direct and
diagonal neighbours. Thus, the total number of hybrid patterns removing
pixels 1,2,3,4,6,7,8 and 9 are ∑ 8Ci���� � 256 The convex contour
patterns constructed from pattern A are shown below.
Table 4.1: 15 Convex Patterns
Note that the direction codes for all 16 convex contour patterns are given
below the respective patterns. For instance, the direction code for the
pattern A is R-D-L-U and the direction code for the pattern B3 is R-DR-
D-L-U.
Table 4.2: 15 Concave Patterns
54
The 15 concave patterns constructed from the pattern A are shown in
table 4.2. One can also construct a total of 225 more patterns from the
pattern A as shown below and determine their direction codes. Thus a
total of 256 patterns could be generated in the 3X3 array of vertices.
Table 4.3: 225 Hybrid Patterns
55
56
57
All these 256 patterns form the basic alphabet of what we call as a digital
picture language. That is, one can visualize any digital image as a spatial
distribution of these patterns. Once such patterns are generated for a
given image, it can then be used for the successful classification of
objects.
4.4.1. Mathematical description of patterns
Figure 4.5: Representation of pattern A
Mathematically, pattern A can be described as,
A = �� = 8 ��
�
thus patterns B1,B3,B7,B9 = �� � ��
�� 7 ��
�
The mathematical description of all the 256 patterns are shown in the
following table
a
a/2
58
Table 4.4: Mathematical description of 256 patterns
No Patterns Mathematical
Description
1. A �� = 8 ��
�
2. B1, B3, B7, B9 ��- ��
� = 7 ��
�
3. B2, B4, B6, B8 , C13, C17, C19, C37, C39, C79 �� - 2 ��
� = 6 ��
�
4. B12, B14, B32, B34, B36, B74, B78, B96, B98, B18, B16, B38, B72, B76, B92,
B94, D137, D139, D179, D379 �� - 3 ��
� = 5 ��
�
5.
C28, C46, B132, B134, B136, B138, B172, B174, B176, B178, B192, B194, B196,
B198, B372, B374, B376, B378, B392, B394, B396, B398, B792, B794, B796,
B798, C124, C326, C748, C968, E1379
�� − 4��
8
= 4��
8
6. C24, C26, C48, C68 4��
8+
�√2
7. E2468 4�
√2
8.
C128, C146, C328, C346, C728, C746, C928, C946, C1324, C1326, C1724, C1748,
C1924, C1968, C3726, C3748, C3926, C3968, C7948, C7968, B1372, B1374, B1376,
B1378, B1392, B1394, B1396, B1398, B1792, B1794, B1796, B1798, B3792, B3794,
B3796, B3798
�� − 5��
8
= 3��
8
9. C126, C148, C168, C324, C348, C368, C724, C726, C768, C924, C926, C948 3��
8+
�√2
10. D13468, D17268, D39248, D79246, E12468, E32468, E72468, E92468 3�
√2
11.
C1328, C1746, C1928, C1946, C3728, C3746, C3946, C7928, D13246, D17248,
D39268, D79468,C13724, C13726, C13924, C13926, C13968, C17924, C17948,
C17968, C37926, C37948, C37968,B13792, B13794, B13796, B13798
�� − 6��
8
= 2��
8
59
12. D246, D248, D268, D468 2��
8+ 2
�√2
13.
D1246, D1248, D3246, D3268, D7248, D7468, D9268, D9468, C1346, C1348,
C1368, C1726, C1728,C1768, C1926, C1948, C3724, C3768, C3924, C3928, C3948,
C7924, C7926, C7946
2��
8+
�√2
14. E132468, E172468, E192468, E372468, E392468, E792468, D137268, D137468,
D139248, D139468,D179246, D179268, D379246, D379248, D137928, C137946 2
�√2
15. D137246, D137248, D139246, D139268, D179248, D179468, D379268, D379468,
C137924, C137926,C137948, C137968
�� − 7��
8
=��
8
16. D1268, D1468, D3248, D3468, D7246, D7268, D9246, D9248 ��
8+ 2
�√2
17.
D13248, D13268, D17246, D17468, D19246, D19248, D19268, D19468, D37246,
D37248, D37268,D37468, D39246, D39468, D79248, D79268, C13728, C13746, 13748,
C13768, C13928, C13946,C13948, C17926, C17928, C17946, C37924, C37928, C37946
��
8+
�√2
18. E1372468, E1392468, E1792468, E3792468, D1379246, D1379248, D1379268, D1379468 �
√2
19. E13792468 Nil
4.5. DLC generation of images
For utility point of view, here we represent a knowledge about a square
as <x1,y1>/Rn*DRn*Dn*DLn*Ln*ULn*Un*URn/<x2,y2># instead of
R�DR�D�DL�L�UL�U�UR*n�n�n�n�n�n�n�n. <x1,y1> refers to
the coordinates of the starting point, the delimiter * denotes change in
direction, <x2,y2> refers to the coordinates of the end point of the
60
contour component. The pseudo code for generating the DLC code for
an image is given below:
Pseudo Code for DLC Generation
Step 1 : Trace the pixels in the image starting from pixel position (1,1) to
find the initial foreground pixel (xi,yi) with the intensity value 1.
This point identifies the initial point of the first component present
in the image.
Step 2 : Trace the pixels in the preferential directions (R, DR, D, DL, L,UL,
U, UR) for finding the connected pixels (pixels with the same value).
Step 3: Repeat step 2 removing the traced pixels (setting the value to 0) till
there exists a point (xj,yj) with no neighbouring connected pixels.
Step 4 : Print the vector code – (xi,yi) as the initial point, the directions
traced with respective length (number of pixels), (xj,yj) as the end
point and # as the delimiter to the next component.
Step 5 : Go back to position (xi,yi+1) and repeat step2 –step4.
Step 6 : The final vector code gives the components present in
the given image.
Consider an image of a square. The knowledge vector of a square is
(a) Image (b) Contour
(c) Knowledge vector
Figure 4.6: Image of a square, its contour map and the
corresponding knowledge vector
<104,109>/R81*D81*L81*U80*/<105,109>
61
One can easily say that the above knowledge vector represents a
square from the fact that the four directions R,D,L and U has the same
length except the direction U that has 1 pixel less than other 3 sides. This
is because of the immediate removal of the scanned pixels. The end point
is <105, 109> as the starting pixel point <104,109> is removed after the
scan.
4.6. Gap filling
When the pixels in an image are sparse the number of components in
DLC becomes large making the identification process complicated. So to
reduce the complexity of the problem a gap filling algorithm is
introduced to fill the small gaps present as noise in the image.
Figure 4.7: Higher order pixel representation
When the immediate neighbour of a pixel is not present, the
algorithm looks for the pixels in the next level in the order of preferential
directions. If pixels found in the next level, the algorithm connects the
62
present pixel position to that in the next level to form connectivity thus
filling the gap between pixels. The pseudo code is given below.
Pseudo Code for Gap filling
Step 1 : Start from pixel position (1,1) and trace the image for printing the
DLC of components. Let (xi,yi) be the initial point of the ith
component.
Step 2 : If there exists a pixel (xm,ym) whose immediate neighbouring pixels
are not connected check for the pixel (xn,yn) with value 1 in the next
level in the preferential order of directions.
Step 3: If found, connect pixels (xm,ym) and (xn,yn) and continue tracing to
generate the DLC for that component.
Step 4 : else, go back to position (xi,yj+1) and trace the image for the next
component.
Step 5 : Print the final vector codes of the components present in the image
Let us consider the rectangle shown below
(a) Image (b) Contour
(c) Knowledge vector
Figure 4.8: Rectangle, its contour and knowledge vector
It is observed from Figure 4.8 that the above shape has 2 components
as there is a pixel gap at <43,302>. The gap filling algorithm is used and
the knowledge vector obtained after gap filling is
<42,28>/R273*/<42,301>#<43,28>/D236*R275*U235*/<44,303>#
63
(a) Rectangle contour (b) Knowledge vector
Figure 4.9: Knowledge vector of a rectangle after gap filling
4.7. Componentwise Image Description and
Regeneration
Let us consider the contour of the digital image Figure 4.10 consisting of
four squares (not ideal squares).
a) Original image b) Contour map
Figure 4.10: Sample image consisting of four squares
The DLC generating algorithm was applied to this image and the
knowledge string was obtained. Table 4.5 shows the component wise
retrieval of the knowledge string for each component in the image.
<42,28>/R273*DR2*D235*L275*U236*/<43,28>#
64
Table 4.5: Component wise extraction of the Knowledge string.
Step Components Knowledge string
1.
<19,23>/R212*D223*L212*U222*/<20,23>#
2.
<50,56>/R151*D159*L151*U158*/<51,56>#
3.
<78,83>/R100*D104*L100*U103*/<79,83>#
4.
<99,107>/R56*D58*L56*U57*/<100,107>#
The bottom-up processing is also done to recognize the object by
redrawing the same using the knowledge string to verify the accuracy of
the DLC generating algorithm. The pseudo code for regenerating the
images is given below.
Pseudo Code for redrawing the images using the DLC
Step 1 : Read the DLC of an image.
Step 2 : Mark the starting pixel point of the first component.
Step 3: Trace the pixels in all the directions present as the direction code in
DLC and for the respective length setting the value of the pixels
to 1.
Step 4 : Repeat step 2,3 for all the components present in the DLC.
Step 5 : The final plot gives the image of the input shape taken for DLC
generation.
65
Table 4.6: Redrawn images of squares from the extracted knowledge.
No Knowledge string Component
1. <19,23>/R212*D223*L212*U222*/<20,23>#
2. <50,56>/R151*D159*L151*U158*/<51,56>#
3. <78,83>/R100*D104*L100*U103*/<79,83>#
4. <99,107>/R56*D58*L56*U57*/<100,107>#
The knowledge base consists of the various components of the image.
Large knowledge bases could be then processed and classified using
knowledge manipulation and classification algorithms.
66
4.8. Component Analysis
The relationship among the components need to be studied to identify
the component as a part of an object or as another object. More analysis
of the knowledge vector helps to make the identification process easier.
Some approximate measures can be done and further the knowledge
vector can be normalized to make it a suitable input for the classification
process to identify the shape of an object as a member of one of the
existing shape classes.
This whole process of Vector Analysis and Normalization and
Artificial Neural Network based classification is discussed in the
next chapter.