12
1 Abstract A novel motion detection method is proposed and its properties are investigated. It combines the pseudo-random scan proposed elsewhere with a simple and efficient feature detector inspired from cellular automata dynamics to detect noisy parts of the scanned image. As an effect of pseudo-random scan, moving parts are transformed in noisy image patches. Their presence can be conveniently detected using the clustering coefficient previously introduced in cellular automata research. Certain parameters such as the number of samples acquired in each frame and the threshold in the feature detector allow identifying moving patches with different speeds and sizes. Experimental results suggest computational efficiency when compared to traditional motion detection approaches. Index Termsimage scan, cellular automata, motion detection, feature extraction, nonlinear dynamics; I. INTRODUCTION RTIFICIAL motion detection algorithms are usually based on image processing of the visual data acquired traditionally via raster scanning methods (image is subdivided into a sequence of usually horizontal strips known as "scan lines") and varies from basic frame difference, median filter [1][2] to more complex and specialized algorithms as motion history image (MHI) [3], with the purpose to obtain motion information, which further, is required for the solution of many complex tasks of the visual system such as feature extraction, classification, object recognition, tracking, depth perception and object/background discrimination by relative motion. However the motion detection utilized in nature diverges from artificial methods. A biological point of view employs a different approach to the motion detection paradigm. The visual information captured by the eye is processed by the brain to give a percept that does not correspond with a physical measurement of the stimulus source. In other words, the brain's visual processing system compensates for a lack of information in one area of the visual field by making an educated guess from information elsewhere in the visual field ("filling-in" and "subjective contour")[4]. This functionality of the human visual system can be simulated at a certain amount of degree using our chaotic-scan approach. Instead of covering each pixel and each line, the algorithm achieves a pseudo-random scan of the video frame, this way only changes will appear as evident and new visual information, therefore simulating at some level the biological visual system. In this letter we show that by simply replacing the traditional raster scan of a sensor array with a chaotic scan results in multiple benefits in terms of motion detection and fast feature extraction. Based on the Cluster Coefficient [5] adapted and implemented for video data, the proposed chaotic scan is a very simplified model of eye saccades where chaotic nonlinear dynamics is exploited to scan the visual field. Unlike previous implementations of saccadic sensors (e.g. in [6]) the resulting sensor is not a foveated one, and therefore no sophisticated control mechanisms of the motion as described in [7] or [8] are implemented. The remaining of this paper is organized as follows: In Section II a pseudo-random scan in video is presented and their properties are introduced. Motion detection using pseudo-random scan algorithm is investigated in section III. Section IV introduces the use of a Clustering Coefficient (CC) as a detector of “noisiness” images (a method to detect the degree of change contained into an image). Simulation results for various circumstances of using the proposed system are provided in Section V, investigations are made on international certified iLids database. II. PSEUDO-RANDOM SCAN IN VIDEOS The pseudo-random scan utilized in current paper is based on a Hybrid Cellular Automaton (HCA) described in [9]. The discrete-time dynamics of the HCA is given by the next equation, which applies synchronously to all cells (a cell is identified by an index n i ,.. 2 , 1 ): A pseudo-random scan perspective to the motion detection paradigm Catalin Mitrea, Bogdan Ionescu, Radu Dogaru A

A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

1

Abstract — A novel motion detection method is proposed and its properties are investigated. It combines the pseudo-random scan

proposed elsewhere with a simple and efficient feature detector inspired from cellular automata dynamics to detect noisy parts of the

scanned image. As an effect of pseudo-random scan, moving parts are transformed in noisy image patches. Their presence can be

conveniently detected using the clustering coefficient previously introduced in cellular automata research. Certain parameters such as

the number of samples acquired in each frame and the threshold in the feature detector allow identifying moving patches with

different speeds and sizes. Experimental results suggest computational efficiency when compared to traditional motion detection

approaches.

Index Terms— image scan, cellular automata, motion detection, feature extraction, nonlinear dynamics;

I. INTRODUCTION

RTIFICIAL motion detection algorithms are usually based on image processing of the visual data acquired traditionally via

raster scanning methods (image is subdivided into a sequence of usually horizontal strips known as "scan lines") and varies

from basic frame difference, median filter [1][2] to more complex and specialized algorithms as motion history image (MHI) [3],

with the purpose to obtain motion information, which further, is required for the solution of many complex tasks of the visual

system such as feature extraction, classification, object recognition, tracking, depth perception and object/background

discrimination by relative motion. However the motion detection utilized in nature diverges from artificial methods. A biological

point of view employs a different approach to the motion detection paradigm. The visual information captured by the eye is

processed by the brain to give a percept that does not correspond with a physical measurement of the stimulus source. In other

words, the brain's visual processing system compensates for a lack of information in one area of the visual field by making an

educated guess from information elsewhere in the visual field ("filling-in" and "subjective contour")[4]. This functionality of the

human visual system can be simulated at a certain amount of degree using our chaotic-scan approach. Instead of covering each

pixel and each line, the algorithm achieves a pseudo-random scan of the video frame, this way only changes will appear as

evident and new visual information, therefore simulating at some level the biological visual system. In this letter we show that

by simply replacing the traditional raster scan of a sensor array with a chaotic scan results in multiple benefits in terms of motion

detection and fast feature extraction. Based on the Cluster Coefficient [5] adapted and implemented for video data, the proposed

chaotic scan is a very simplified model of eye saccades where chaotic nonlinear dynamics is exploited to scan the visual field.

Unlike previous implementations of saccadic sensors (e.g. in [6]) the resulting sensor is not a foveated one, and therefore no

sophisticated control mechanisms of the motion as described in [7] or [8] are implemented.

The remaining of this paper is organized as follows: In Section II a pseudo-random scan in video is presented and their properties

are introduced. Motion detection using pseudo-random scan algorithm is investigated in section III. Section IV introduces the use

of a Clustering Coefficient (CC) as a detector of “noisiness” images (a method to detect the degree of change contained into an

image). Simulation results for various circumstances of using the proposed system are provided in Section V, investigations are

made on international certified iLids database.

II. PSEUDO-RANDOM SCAN IN VIDEOS

The pseudo-random scan utilized in current paper is based on a Hybrid Cellular Automaton (HCA) described in [9]. The

discrete-time dynamics of the HCA is given by the next equation, which applies synchronously to all cells (a cell is identified by

an index ni ,..2,1 ):

A pseudo-random scan perspective to the

motion detection paradigm

Catalin Mitrea, Bogdan Ionescu, Radu Dogaru

A

Page 2: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

2

IDtxtxtxCellmtx T

i

T

i

T

ii

T

i ,)),(,)1( 11 (1)

where “i” represents a pixel address and it is a binary vector ].,,..,,[ 21

i

n

i

j

ii

i xxxxX with n elements 1,0ijx and n

represents the counter size. A perfect scanning counter should count all nN 2 possible states corresponding to the same

number of pixels in the array. The upper index “T” stands for the transmitting CA counter (i.e. embedded within the sensor in the

proposed transmission system), is the logical XOR operator and IDuuuCell ,3,2,1 is a Boolean function with 3 binary

inputs (u1,u2, and u3). In its binary representation, the most significant bit of ID corresponds to the cell output when

]1,1,1[]1,2,3[ uuu . A periodic boundary condition is assumed i.e. the leftmost cell (i=1) is connected to the rightmost one (i=n).

The binary mask vector nmmm ,..,, 21m is optimized [10] for any odd counter size up to 29n an optimal value of such that

12/ nNr . In our simulations from the following chapters we used a mask m = [ 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0 ]

and a resolution of 406 x 323 = 131138 pixels. With n = 17 there are covered 2^17 pixels (131072 - 1).

A Chaotic versus raster scan counters

To understand the basic difference between chaotic and raster scan counters an array of 30N pixels addressed by the two

possible counters is considered in Figure 1. In the case of the raster scan (Figure 1a) consecutive states correspond to adjacent

pixels, while in the case of a chaotic counter consecutive states correspond to rather distant pixels.

For a Gray code encoding the geometrical distance between consecutively visited pixels is:

n

j

ij

ijkkk

kk xxiid1

11, . This

distance is constant ( 1kd ) for the raster counter while it obeys a Gaussian distribution with an average value nd k 5.0 in the

case of chaotic (pseudo-random) counters (Figure 1c). The average distance between consecutive pixels (“jump”) called in the

next spreading is large (see Figure 1b) in the case of chaotic counters allowing a fast coverage of the visual field.

Figure 1. a) Circular state diagrams for a normal (raster scan) counter; b) The same diagram for a chaotic counter, here the HCA with ID=101 and 5n .

c) Distribution of distances between consecutive pixels in the case of both chaotic counters with 17n cells.

B. Properties of chaotic counters: fast coverage

Let assume that the initial state of a scan is 1i in Figure 1. Let now consider a compact object (its pixels are correlated)

starting with position (state) m in the counting cycle (Figure 1a,b). The time until discovery discT is defined as the average number

of iterations until reaching at least one pixel of the object. With the constant “jump” of 1 in the case of the normal counter and

with the average “jump” of 0.5n in the case of the chaotic counter, it follows that:

mmT disc (2)

in the case of the normal (raster scan) counter, and

nmnmmT /25.0/disc (2’)

in the case of chaotic counter. Obviously, the chaotic scan is much faster that the raster scan in exploring the visual field.

It follows that a chaotic counter explores the entire pixel array (m=N) after only nNT /2coverage cycles.

C. Features of the chaotic scan transmission system

The main features of the chaotic scan system are summarized in Table I, against the traditional raster scan system [9].

Page 3: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

3

TABLE I. A LIST OF RELEVANT FEATURES OF THE CHAOTIC SCAN (CS) COMPARED TO THE TRADITIONAL RASTER SCAN (RS)

No Features Chaotic

Scan

Raster

Scan

1 Embedded image compression YES NO

2 Embedded encryption capabilities YES NO

3 Spread spectrum transmission

(un-correlated consecutive pixels)

YES NO

4 Fast feature detection

capabilities

YES NO

While the points 1, 2 and 3 were demonstrated in [9], we will concentrate only on last point (Fast feature detection) by using

the histograms and Clustering Coefficient implemented in Chapter IV. Various features (e.g. histograms) or motion in the visual

field can be detected faster, based on a small fraction of pixels from the sensing array. An example is given in Figure 2 and

Figure 3. With chaotic scan it is obvious that even after sending a small amount of pixels (less than 0,2% of the whole image) a

histogram approximating quite well the one of the entire image is obtained. In the case of the raster scan, as seen in Figure 3,

recovering the histogram of the whole image after sending only a small fraction of highly correlated pixels is not possible. Such a

feature is favorable to those applications where the exact content of the image is less important than histograms (e.g. feature

recognition, detecting transitions in video scene, motion detection etc.).

Figure 2. Histograms of Lena image obtained after different numbers m of pixels being sent and received when the sensor array is addressed using a chaotic counter. Note the good match with the final histogram after sending only 0.2% of all pixels.

Figure 3. Histograms of Lena image obtained after different numbers m of pixels being sent and received when the sensor array is addressed using a raster counter. In this case there are large differences in histograms and one should wait for an entire frame in order to recover a valid histogram.

III. MOTION DETECTION USING PSEUDO-RANDOM SCAN

In this section a two methods of motion detection is used, comparing the raster-scan with chaotic-scan on a webcam video as a

source. Motion detection algorithms are basic frame difference and Motion History Image (MHI), at different object speeds and

sizes. For speed and optimization considerations the implementation is made in OpenCV (Intel open library for video

processing). In MHI case, with green is enclosed the moving object detected, while with red a global motion is represented).

MHI algorithm is described by the following function:

( ) {

( )

( ) ( ) ( )

(3)

where MHI is motion history image that is updated by the function (single-channel); silhouette is the silhouette mask that has

non-zero pixels where the motion occurs; timestamp is current time in milliseconds or other units and duration is maximal

duration of the motion track in the same units as timestamp. That is, MHI pixels where the motion occurs are set to the current

timestamp, while the pixels where the motion happened last time are cleared.

Page 4: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

4

Figure 4: Relative reduced speed of the object. At basic frame difference motion is detected in chaotic scan case; No detection is detected

in raster scan case.

(a) Raster scan (b) Frame Difference (c) MHI

(d) Chaotic scan (e) Frame Difference (f) MHI

(d) Chaotic scan (e) Frame Difference (f) MHI

(a) Raster scan (b) Frame Difference (c) MHI

Page 5: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

5

Figure 5. Intermediate speed of the interest object.

Figure 6. Relative high speed of the interest object.

In all cases the chaotic scan method and raster scan shares similar results both in frame difference and MHI cases. Chaotic scan

seems to be more sensible at reduced speeds of the interest object.

IV. NOISY IMAGE DETECTORS BASED ON CLUSTERING COEFICIENT

In this chapter a Clustering Coefficient (CC) algorithm, initially proposed in [9] for audio processing tasks, is used to analyze the

“noisiness” level of each video frame in real time. The cluster coefficient can be interpreted as a method to detect the level of

changes of pixel values in the analyzed frames. The mathematical formula to compute the CC transform is described below:

( )

∑ ∑ |

( )

( )

( )

( )

|

(4)

where {St}t=0,..,w-1 is a video signal sequence with w samples and assuming that a power of 2, with n = log2 (w), the CC transform

computes an n-3 sized output S(k)k=0,..,n-4. The values S(1),...S(n - 4) are introduced to provide more spectral information i.e.

about the clustering coefficient at lower sampling frequencies (S(k) has a the sampling frequency 2 times less than that used to

calculate S(k-1)) and therefore the output vector provides a synthetic information about the distribution of information within

different bands of frequencies spanning the signal spectrum. Following is a simulation in Matlab of the clustering coefficient of

the static image of “Lena” (Figure 7).

(a) Raster scan (b) Frame Difference (c) MHI

(d) Chaotic scan (e) Frame Difference (f) MHI

Page 6: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

6

Figure 7: (a) Original Picture. (b) Clustering Coefficient visual representation. (C) Matlab plotting

In Figure 7: CC Image represents the visual representation where “changes” occur in pixel value, and CC Plot is the 2D

graphical representation of the average of column pixels values of the CC Image (with respect to the Original Image width).

While the “changes” in pixel values increases, the values of the CC transform will decrease to 0. For a better understanding of

the clustering coefficient and its ability to quantify the level of “noisiness” contained into a video frame the following image was

constructed, as an example, composed of basic different object shapes.

Figure 8: (a) Simple shapes. (b) Clustering Coefficient visual representation. (C) Matlab plotting of the CC Image with respect to original image

width. It can be observed that each shape Original Image creates its own CC image-shape and CC Plot..

In Figure 8 it can be observed that each shape incorporates a certain degree of “change”. A CC Image representation of the first

four shapes (the circle, square, triangle and hexagon) presents similarities with the Original Image (the shape is doubled and

inner to original one). This is an implication of the CC algorithm which detects the areas of the frame where the pixels value is

changing (e.g. at borders of the object). For speed processing considerations the rest of the simulations are conducted in

OpenCV. Following is the simulation of the clustering coefficient using a webcam as a video source. For convenience on

reading and interpretation the clustering coefficient plot is flipped vertically (CC Plot).

(a) Original Picture (b) CC Image

(c) CC Plot

(a) Original Picture

(b) CC Image

(c) Matlab CC Plot

Page 7: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

7

Figure 9: Initial states, no motion. Both raster and chaotic cluster coefficient presents similar values (c) and (f).Obviously if no motion

is detected, CC Images and CC Plots presents similarities.

Figure 10: Initial motion. Chaotic scan CC Plot has an increased level of “noisiness” in captured video frames (f – compared with c)

(a) Raster scan (b) CC Image (c) CC Plot

(d) Chaotic scan (e) CC Image (f) CC Plot

(a) Raster scan (b) CC Image (c) CC Plot

(d) Chaotic scan (e) CC Image (f) CC Plot

(a) Raster scan (b) CC Image (c) CC Plot

Page 8: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

8

Figure 11: While the speed of the object increases also the values of the clustering coefficient increases (f), signaling a high degree of changing in pixel values.

In raster case the indications remains relatively unchanged (compared with Figure 10).

V. EXPERIMENTAL RESULTS

In the following simulations, a video library from iLids [11] database (international certified video database for intelligent

video processing testing and evaluation) was used as a video image source with the purpose to detect any intrudes into a “Sterile-

Zone”. The task of detecting people entering a sterile zone is a common scenario for visual surveillance systems. One example

scenario is detecting people entering a high secured zone. The main challenge for the academic and industrial communities is to

demonstrate robust operation over a wide range of environmental conditions. We choose to take the simulations on sterile zone

that implies night video surveillance conditions (IR video camera) which continues to be a difficult task in intruder detection on

many motion detection algorithms.

Figure 12: Night conditions. No movement on scene. Observe similar values of the clustering coefficient in both raster and chaotic scan (c and f).

(d) Chaotic scan (e) CC Image (f) CC Plot

(a) Raster scan (b) MHI (c) CC Plot

(d) Chaotic scan (e) MHI (f) CC Plot

Page 9: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

9

Figure 13: Night conditions, Initial movement, human appears in scene. It can be observed increased value of the clustering coefficient in chaotic scan case (f).

(a) Raster scan (b) MHI (c) CC Plot

(a) Raster scan (b) MHI (c) CC Plot

(d) Chaotic scan (e) MHI (f) CC Plot

Page 10: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

10

Figure 14: Night conditions. Movement, human stops at fence. It can be observed increased number of the clustering coefficient in chaotic scan case (f)

comparing with Figure 13 (f). Both chaotic and raster scan methods behave similar results when using MHI motion detection algorithm but chaotic scan

outperforms raster scan when CC algorithm is used.

VI. CONCLUSIONS

A pseudo-random scan to the motion detection paradigm was investigated. It was demonstrated that in the case of simple motion

detection methods (frame difference) and more complex ones (MHI), chaotic scan is promising comparable results with

traditional raster scan approaches. A novel method (Clustering Coefficient - CC) for motion detection was adapted and

implemented with enhanced results (more evident) in the case of chaotic scan. The CC algorithm can be adapted and

implemented to detect motion and extract at some point relevant feature. Based on the observation that natural systems explore

the visual field chaotically to rapidly discover and focus on novel relevant patterns, Cluster Coefficient algorithm can be

employee as a measure of change degree (noisiness level) in the pixels composing a video frame. This method provides several

useful features including fast pattern recognition. Since relevant features can be extracted without waiting for the entire frame to

be scanned, the chaotic scan eliminates the notion of “frame” and its associated latency (frame rate) allowing a flexible operation

of the sensor with a variable pixel rate.

REFERENCES

[1] Sen-Ching S. Cheung, Chandrika Kamatah – Robust techniques for background subtraction in urban traffic videos, 2007.

[2] Rita Cucchiara, Costano Grana, Massimo Piccardi, Andrea Prati – Detecting Moving Objects, Ghosts, and Shadows in Video Streams, IEEE Transactions

on Pattern Analysis and Machine Intelligence, Volumul 25, Numărul 10, Octombrie 2003, pag. 1337-1342.

[3 ]Md. Atiqur Rahman Ahad, J. K. Tan, H. Kim: Motion history image: its variants and applications, 2010

[4] Werner, J. S., Pinna, B. & Spillmann, L. [2007] “Illusory color and the brain,” Sci. Amer. 296, 70–75.

[5] [20] Radu Dogaru: Fast and Efficient Speech Signal Classification with a Novel Nonlinear transform.

[6] R. Etienne-Cummings, J. Van der Spiegel, P. Mueller, and M.-Z. Zhang, “A foveated silicon retina for two-dimensional tracking,” IEEE Trans. Circuits

Syst. 2, vol. 47, no. 6, pp. 504–517, Jun. 2000.

[7] W. Wong and R. I. Homsey, “Design of an electronic saccadic imaging system,” in Proc. Can. Conf. Electr. Comput. Eng. CCGEI 2004 Niagara Falls,

2004, pp. 2227–2230.

[8] N. Srinivasa and R. Sharma, “Execution of saccades for active vision using a neurocontroller,” IEEE Control Syst. Mag., vol. 17, no. 2,

pp. 18–29, Apr. 1997.

[9] Radu Dogaru, Member, IEEE, Ioana Dogaru, and Hyongsuk Kim, Member, IEEE: Chaotic Scan: A Low Complexity Video Transmission System for

Efficiently Sending Relevant Image Features.

[10]R. Dogaru and H. Kim, “Low complexity image compression an transmission based on synchronized cellular automata,” in Proc. 10th Int. Workshop

Multimedia Signal Process. Transmission (MSPT), Jeonju, Korea, Jul., pp. 43–48.

[11] http://www.securiton.com/en/ch/products/video-surveillance/videomanagement/ips-videomanager/i-lids-certification.html

(d) Raster scan (e) MHI (f) CC Plot

Page 11: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

11

ANNEX 1 //OpenCV implementation of the Cluster Coefficient function (CC)

void Cluster_Des_haotic (IplImage * poza_analiza) { std::vector<float> date_poza; std::vector<float> date_arata; std::vector<float> date_grafic; Mat rez_dim; CvMat * param = cvCreateMat(poza_analiza->height,poza_analiza->width,CV_32F); CvMat * rez = cvCreateMat(poza_analiza->height,poza_analiza->width,CV_32F); cvSetZero( param ); cvSetZero( rez ); for( int r = 0; r < poza_analiza->height; r++ ) { UCHAR * row = ( UCHAR * )( poza_analiza->imageData + r * poza_analiza->widthStep ); for( int c = 0; c < poza_analiza->width; c++ ) { date_poza.push_back( ( float )( row[ c ] ) ); }; }; std::sort(date_poza.begin(), date_poza.end()); float min_p, max_p; min_p = date_poza.at(0); max_p = date_poza.at(date_poza.size() - 1); for(int i = 0; i < poza_analiza->width * poza_analiza->height; i++) { int index = ( i / poza_analiza->width ); index = index * poza_analiza->widthStep + i % poza_analiza->width; float tmp = -1 + (poza_analiza->imageData[index] - min_p)/(max_p - min_p); param->data.fl[i] = tmp; } for(int i = 0; i < param->rows ; i++) { for( int j = 0; j < param->cols ; j++) { float tmp = param->data.fl[i * poza_analiza->width + j + 1] + // tmp = S(k) param->data.fl[i * poza_analiza->width + j + 1] + param->data.fl[(i + 1) * poza_analiza->width + j ] + param->data.fl[(i + 1) * poza_analiza->width + j ] - 4 * param->data.fl[i * poza_analiza->width + j ]; rez->data.fl[i * rez->cols + j] = 1 - 0.25 * int (tmp); } } cvShowImage("Img_clust.descriptor_HAOTIC", (rez));// CC Image CvMat * NorRez = cvCreateMat( rez->height, rez->width, CV_32F ); for( int i = 0; i < rez->rows; i++ ) { for( int j = 0; j < rez->cols; j++ ) { NorRez->data.fl[ i * rez->cols + j ] = rez->data.fl[ i * rez->cols + j ] < 1 ? 255 : 0.0; }; }; CvMat * ColSum = cvCreateMat( 1, rez->width, CV_64FC1 ); cvSetZero( ColSum ); for( int i = 0; i < rez->rows; i++ ) { for( int j = 0; j < rez->cols; j++ ) { ColSum->data.db[ j ] += NorRez->data.fl[ i * rez->cols + j ]; }; }; CvMat * NormColSum = cvCreateMat( 1, rez->width, CV_64FC1 ); cvSetZero( NormColSum );

Page 12: A pseudo-random scan perspective to the motion detection ...sdettib.pub.ro/admin/images/raport/2013-07-09... · A Chaotic versus raster scan counters To understand the basic difference

12

CvMat * Graph = cvCreateMat( rez->height, rez->width, CV_64FC1 ); double fmaxt = 0.00, fmint = INT_MAX; for( int i = 0; i < ColSum->width; i++ ) { ColSum->data.db[ i ] /= rez->rows; fmaxt = max( fmaxt, ColSum->data.db[ i ] ); fmint = min( fmint, ColSum->data.db[ i ] ); }; for( int i = 0; i < NormColSum->width; i++ ) { NormColSum->data.db[ i ] = ( ColSum->data.db[ i ] / fmaxt ) * rez->height; if( NormColSum->data.db[ i ] < 1.0 ) NormColSum->data.db[ i ] = 1.0; }; ; cvSetZero( Graph ); for( int i = 0; i < ColSum->width; i++ ) { double fval = NormColSum->data.db[ i ]; //int r = max( ( int )( fval ) - 1, 0 ); // rotire afisare CC Plot int r = min( max( rez->height - fval, 0 ), rez->height-1 ); Graph->data.db[ r * Graph->width + i ] = 255; }; cvShowImage("clustering.descriptor_haotic|0 to 1|", (Graph)); // Imagine CC Plot cvReleaseMat( &NorRez ); cvReleaseMat( &rez ); cvReleaseMat( &ColSum ); cvReleaseMat( &NormColSum ); cvReleaseMat( &Graph ); cvReleaseMat( &param ); };