• No results found

5.3 Structural Properties of a Linear Array

5.3.1 Pre-processing Algorithm

The goal that the pre-processing algorithm tries to achieve is to determine the minimum number of iterations that is required to perform an image operation. It is first required to identify the areas of interest and then determine the number of repeti­ tions for the operation by counting the total number of rows occupied by those areas. In order to simplify the problem, only binary images are considered and objects are represented by pixels of ‘1 \ whilst background has pixels of ‘O’. If grey-level images are considered then a different algorithm is required. The effectiveness of the pre­ processing algorithm also depends on other factors which are independent of the types of images under consideration and further discussion is included in later paragraphs. Using a binary image as an example provides sufficient information to determine the effectiveness of such an algorithm.

The most straightforward method to evaluate the number of iterations required is by counting the number of non-zero rows of the input image, because the background has value 0. However, such a method will not cater for more complex situations and three different cases should be considered.

The three different cases include images which have a single object, multiple objects without overlap, and multiple objects with overlapping, as shown in Fig. 5.12. The term overlap applies to any objects which have pixels located in the same column (or the X coordinate). If there is only one object appearing in the input image then the number of iterations is equivalent to its height (or the number of rows occupied by it). When more than one object is present, without overlap, then the height of the tallest object will determine the iterations needed. Overlapped objects are treated as a single object, as shown in Fig. 5.12(c). This is because pixels in the same column are pro­ cessed by a single PE, therefore, there is no easy solution to operate on different objects having pixels in the same column in parallel. In the last case, the number of iterations is still determined by the height of the tallest object but now overlapping objects are treated as a single entity.

The algorithm first scans through the image from top to bottom and a vector V 1 which stores the Y coordinate of the first pixel of each object is obtained. This is fol­ lowed by a bottom up scan and this time vector V2 is generated. V2 contains all the Y coordinate of the last pixel of each object. The maximum height of the objects will determine the number of repetitions of a single operation that must be applied. The maximum height is evaluated by subtracting VI from V2 and the maximum value in the resultant vector is equivalent to the maximum height. Objects are shifted to the top of the image and operations are applied to the objects with the number of repetitions

Height of an object

(a) Image with a single object

Height of the tallest object

(b) Image with objects without overlap

Combined height of two overlapping objects

(c) Image with overlapping objects

determined above. Fig. 5.13 shows how pre-processing can be applied to a binary image containing two objects without overlap and Table 5.4 summarises the timing results obtained from performing the skeletonisation of the image shown in Fig. 5.13 with and without applying the pre-processing function.

thinning with pre-processing algorithm

by fast parallel algorithm

thinning without pre-processing by fast parallel algorithm

no. of repetitions 82 256

time to thin image (ms) 160 500

no. of tables 2 2

pre-processing (ms) 180 0

Table 5.4 Execution time for thinning with and without pre-processing

The execution time of the pre-processing algorithm takes 180ms and the thinning operation takes 160ms so altogether there is an 32% improvement over the original method. There are conditions in which the pre-processing algorithm is not practical. The system scans along the Y-direction, so if an image is densely occupied by object(s) along the Y-direction then the number of repetitions is still large. If a simple operation is to be carried out in the image, e.g. edge finding, then the execution time of the pre-processing algorithm will outweigh the time saved by the reduction of the operation. The effect of applying the pre-processing operation can be expressed by Equation (5.3).

T'=Tr +Tf ^ k ( 5 3 )

T,= total time taken for the complete operation TP= time taken for the pre-processing operation Tf = time taken for the image operation(s) x = number of repetitions

When pre-processing operation is not applied then T,=Tf. The term Tp can be regarded as a constant, but varies with different image formats. If Tp is relatively

(a) Input im age

(b) O bjects shifted to the top o f an im age

(c) Skeletons o f the objects obtained (d) Skeletons m oved to the original positions o f the objects

small then its effect on the term T, is negligible and Ttcan be considered as only pro­ portional to both Tf and x. Dividing (5.3) by 7y, equation (5.4) is obtained.

T * - t p . x (54\

T

The term - j j is the ratio between the total time taken to perform an operation with pre-processing and without. If -jy is small then pre-processing is effective. As dis­ cussed above, this depends on the value of Tf and x, i.e. the execution time of an image operation and the number of iterations required, after pre-processing, to com­ plete such an operation when the value of Tp is small. When Tf is large and both Tp and x are small then pre-processing is advantageous.