1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

kp← 0 //number of blocks on previous image row

bno← 0 //number of the extracted blocks

ono← 0 //number of the extracted objects

while(y

kc← 0 //number of blocks on current row

intervalfound←0

j_curr← 0 //currently examined block of previous row

x←0

while(x

try2match←0

if(img(y,x) AND intervalfound=0) // block’s x1 coordinate

intervalfound←1; x1←x

end if

if (img(y,x)=0 AND intervalfound=1)

intervalfound←0; x2←x-1; try2match←1

end if

if (x=W-1 AND img(y,x) AND intervalfound=1) // row end

x2←x; try2match←1

end if

if (try2match=1) //match interval with blocks of previous row

intervalmatched←0

j_last ←j_curr // last examined block of the previous line

j←j_last

while (j =b[p[j]].x1)

j_curr ← j

if (x1==b[p[j]].x1 AND x2==b[p[j]].x2)

// interval matched with block from previous row

c[kc] ←p[j]; b[p[j]].y2←y; intervalmatched←1

end if

j←j+1

end while

if (intervalmatched=0)

NewBlock(bno, x1, x2, y) //creation of block bno

j_last = j_curr; ii←j_last

while (ii =b[p[ii]].x1-1)

j_curr←ii

// connectivity check with the block of previous row

if((b[bno].x1<=b[p[ii]].x2+1) AND (b[bno].x2>=b[p[ii]].x1-1))

ConnectivityRegistration(bno, p[ii])

if (oid[bno] <0) // block has no object

oid[bno] ← oid[p[ii]] // of left northern neighbor

BlockToObjectRegistration (oid[bno], p[ii])

//add block p[ii] into blocks that make

//up the object with tag bno (oid[bno])

end if

else // resolve the equivalence

ObjectEquivalenceResolve(oid[bno], oid[p[ii])

end if

end if

ii←ii+1

end while

if (oid[bno] <0) // create new object

oid[bno] ← ono+1

BlockToObjectRegistration (oid[bno], b[p[ii]])

end if

c[kc] ← bno+1

end if

kc ← kc+1

end if

x←x+1

end while

p←c ; kp←kc

y←y+1

end while