**4.1.1 Perimeter**

The definition of perimeter is the set of points that make up the shape of the object, in discrete form and is the sum of all pixels that lie on the contour, which can be expressed as:

$$P = \begin{array}{c} \Sigma\_{\text{i}} \ \Sigma\_{\text{i}}\text{pixels (i,j)} \in \text{contour} \end{array} \tag{1}$$

Equation (1) shows how to calculate the perimeter; the problem lies in finding which pixels in the image belong to the perimeter. For searching purposes, the system calculates the perimeter obtaining the number of points around a piece grouping X and Y points coordinates corresponding to the perimeter of the measured piece in clockwise direction. The perimeter calculation for every piece in the Region of Interest (ROI) is performed after the binarization. Search is always accomplished, as mentioned earlier, from top to bottom and left to right. Once a white pixel is found, all the perimeter is calculated with a search function as it is shown in figure 1.

The Use of Contour, Shape and Form in an Integrated Neural Approach for Object Recognition 115

words it is the point where a single support can balance the object. Mathematically, in the

� <sup>∑</sup> <sup>j</sup> �,� Y� � �

The generation of the descriptive vector called The Boundary Object Function (BOF) is based on the Euclidean distance between the object's centroid and the contour. If we assume that P1(X1, Y1) are the centroid coordinates (XC , YC) and P2(X2, Y2) is a point on the perimeter,

The descriptive vector (BOF) in 2D contains the distance calculated in eq. (4) for the whole object's contour. The vector is composed by 180 elements where each element represents the distance data collected every two degrees. The vector is normalized by dividing all the vector elements by the element with maximum value. Figure 2 shows an example where the object is a triangle. In general, the starting point for the vector generation is crucial, so the following rules apply: the first step is to find the longest line passing through the centre of the piece, as shown in Figure 2(a), there are several lines. The longest line is taken and divided by two, taking the centre of the object as reference. Thus, the longest middle part of the line is taken as shown in Figure 2(b) and this is taken as starting point for the BOF vector descriptor generation as shown in Figure 2(c). The object's pattern representation is depicted

The use of shading is taught in art class as an important cue to convey 3D shape in a 2D image. Smooth objects, such as an apple, often present a highlight at points where a reception from the light source makes equal angles with reflection toward the viewer. At the same time, smooth object get increasingly darker as the surface normal becomes perpendicular to rays of illumination. Planar surfaces tend to have a homogeneous appearance in the image with intensity proportional to the angle between the normal to the

(a) (b) (c) (d)

d�P�, P�� � ���� � ���� � �Y� � Y��� (4)

� <sup>∑</sup> <sup>i</sup> �,� (3)

�� � �

discrete domain, the centroid is defined as:

**4.2 Generation of descriptive vector (BOF)** 

then this distance is determined by the following equation:

Fig. 2. Example for the generation of the BOF vector.

where A is obtained from eq. (2)

in Figure 2(d).

**5. Object's form** 

Fig. 1. Perimeter calculation of a workpiece.

The next definitions are useful to understand the algorithm:


The search algorithm executes the following procedures once it has found a white pixel:

Searches for the nearer pixel to the boundary that has not been already located.

Assigns the label of actual pixel to the nearer pixel to the boundary recently found.

Paints the last pixel as a visited pixel.

If the new coordinates are higher than the last higher coordinates, the new values are assigned to the higher coordinates.

If the new coordinates are lower than the last lower coordinates, the new values are assigned to the lower coordinates.

Steps 1 to 5 are repeated until the procedure returns to the initial point, or no other nearer pixel to the boundary is found.

This technique will surround any irregular shape very fast, and will not process useless pixels of the image.
