Next, the color information is discarded from the cropped scan zone, and a simple even
smoothing filter is applied.
The system detects the passing objects by comparing successive frames to deter-
mine when a moving body crosses the scan zone. For this, the difference operation is
continuously applied to the scan zone images. Applying this to 8-bit greyscale images
produces 16-bit difference images, having a [−255, 255] range for their pixel values.
In order to store them as regular 8-bit greyscale images, the absolute operator is ap-
plied, mapping the negative part to the positive one (see section 4 for an alternate way
of mapping the 16-bit difference images to 8-bit ones). The difference operation pro-
duces blank images except when change is present, movement between two consecutive
frames can be detected.
When activity is detected, a pattern of the object is created by extracting vertical
lines from the difference image. The objects’ speeds vary, so a method for obtaining
patterns invariant to the speed was devised. It works by obtaining positional information
of the objects while they are going through the scan zone. The speed is calculated when
the object leaves the zone, and it is used to determine the number of columns to extract
from each snapshot of the difference scan zone. Fig. 2 shows a simple synthetic example
of the speed calculation and scanning process. Note that to calculate the speed of a
moving object, at least two different readings of the object’s edge position from the
same screen side are needed. With this in mind, we see that a scan zone of width w will
only reliably calculate the velocity of objects passing from 1 to w/2 pixels per frame.
Preprocessing is then applied to the obtained pattern: binarization by thresholding,
trimming of upper and lower whitespace, and height normalization, maintaining the
aspect ratio.
Lastly, the preprocessed patterns are classified by dynamic time warping (DTW) as
shown by Sakoe and Chiba in [7]. In our case, the elements that are locally compared
to determine the optimum path are the columns of the patterns, so in a sense the pat-
terns are contracted or expanded horizontally. Two symmetric DTW algorithms were
implemented by dynamic programming. Both were based on production sets involving
the three usual operations of insertion, deletion and substitution. The only difference be-
tween them is the slope constraint condition used: SC0 has no slope constraint, whereas
SC1 has a slope constraint of 1 (see [7, table 1] for more details).
3 Greyscale Patterns
In this work we study the use of grey patterns of different number of grey shades for
classification, rather than binarized ones. For it, a greyscale downsampling algorithm
with thresholding has been implemented.
The algorithm accepts three parameters: white threshold, number of grey shades,
and whether to enable normalization. Its input is a 8 bit (256 shades) greyscale image,
and the output is an image with the specified number of grey shades, evenly distributed
between 0 and 255 (e.g., 2 grey shades get values 0 and 255; 3 get 0, 127 and 255; 4
get 0, 85, 170, 255; etc.). Note that in the following examples, 0 is white and 255 black.
The algorithm works as follows:
208