#### Abstract

We propose a new algorithm based on cellular automation (CA) for preserving -connectivity, . The CA algorithm transforms an initial grid configuration in a grid with same number of holes but without 1-connected components. Also, maximal thinning of -connected components, , is achieved. The grid can be used as initial for investigating properties of initial grid. Computational performances are evaluated and measured on real cases. The obtained results indicate that the proposed approach achieves comparable complexity as standard approaches; however, the speed-up and scalability of the proposed algorithm are not limited by the number of processing nodes.

#### 1. Introduction

The cellular automata (CA) can be considered as an alternative way of computation based on local data flow principles. The concept of CA was first proposed by Neumann in 1950s through self-reproducing systems [1]. Later, the formalization was improved by different authors [2–5] emphasizing different perspectives. The application areas of CA become very different, ranging from biology [6, 7], sociology [8], image processing [9], diffusion of soil pores [10], and so forth.

A CA can be informally represented as a set of regularly and locally connected identical elements. The elements can be in a finite set of states. The CA evolves in discrete time steps, changing the states of elements according to a local rule, which is the same for all elements. The new state of each element depends on its previous state and on the state of its neighbourhood. The neighbourhood is composed of all directly connected elements. The characteristic properties of CAs are therefore locality, discreetness, and synchrony.

Identification of isolated regions in binary images is important problems in image processing, machine vision, porous materials analysis, and many other fields of science. The shrinking of binary picture patterns, which is a step towards the recognition of image objects, has been first investigated, using CAs, by Neumann [1], Thatcher [2], and Levialdi [11]. Parallel versions of these algorithms have been developed in [3, 12]. An improved algorithm with a linear complexity has been proposed in [4, 13].

In this paper we propose a new algorithm for thinning of an arbitrary binary rectangular grid. The algorithm preserves 2 or more levels of connectivity of all components on the grid. Hence, the number of isolated parts is preserved. Also, the thinning is maximal in sense of -connectivity of all components in initial grid, .

The rest of the paper is organized as follows. In Section 2, basic definitions of -connectivity and CAs are introduced. In Section 3, our CA is defined with its properties. Section 4 is devoted to implementation and performance analysis. Finally, the work is summarized in Section 5.

#### 2. Definitions

We consider a cellular automation (CA) as a 2-dimensional lattice network of square cells (grid). Each cell can exist in two different sates, 0 or 1. Usually, state 0 is commonly called “white” and state 1 is commonly called “black.”

Cells of the lattice network change their states in discrete moments in time, time steps. Cell’s next state is defined by* local transition function* (rule). Local transition function manages with altering state of each cell, based on the present state and states of neighbourhood’s cells. We use Moore neighbourhood (Figure 1(a)) and typical enumeration for the rectangular array (Figure 1(b)). We denote state of the central cell in a moment by . Arguments of a local transition function are ordered collections , , , , , , , , of the neighbourhoods cell’s states in time step . We use graphical notation for this (e.g., in Figure 3). This alternation of cell states is synchronous.

**(a)**

**(b)**

Configuration of the cellular automation is the assignment of states to all cells in the grid in a moment starting from an initial configuration . CA is often simulated on a finite grid. In our simulation, boundary cells are in fixed state and remain constant throughout the simulation.

Two cells and are (*weakly*)* adjacent* if . Two black (white) cells and are* connected* if there exists a sequence of black (white) cells , , such that each pair and is adjacent. That sequence , , is a* path* which connects cells and .* Length* of the path is . Cell is start cell and is end cell of the path.* Cycle or closed path* is a path with same start and end cell. *-cycle* is a closed path of length . According to the adjacency, we do not have 3-cycle. 2-cycle is a “column” or “row” with two cells. A maximum connected region of black cells is called a* component*.

Similary, black (white) cells and are* weakly connected* if there exists a sequence of black (white) cells , , such that each pair and is weakly adjacent. A maximum weakly connected region of white cells is called a* hole*. Always there is a single external (infinite) hole. A maximum weakly connected region of black cells is called a* weakly component*.

For the moment, suppose that we have just one component on the grid. Then, we say that component is* k-connected* if its complement has finite holes. Number is the* level of connectivity* of the component . Now, on the same way we can find the level of connectivity for all other components in the grid. For example, in configuration from Figure 2(a), we have three components (one is 3-connected (), one is 2-connected (), and one is 1-connected ()) and three finite holes (, , and ).

**(a)**

**(b)**

**(c)**

Let be a cell. Two black (white) cells are (*weakly*)* connected in neighbourhood of * if there exists a black (white) connected path of cells from the neighbourhood which (weakly) connect these two cells.

We solve the problem of thinning an initial configuration to a configuration with the same number of holes.

#### 3. Cellular Automation and Its Properties

Define a CA with a local transition function which is defined by where or , , , , presents local states of the central cell and its neighbourhoods in some moment from Figure 3.

Applying the local transition function to all cells of an configuration simultaneously, we get the sequence of configurations , , started from some initial configuration . For example, if is the configuration from Figure 2(a), then in Figures 2(b) and 2(c) we have and , .

Theorem 1. *Let be a configuration. CA has the following properties.*(1)*A finite number of time steps exist in which each 1-connected component in vanishes after steps.*(2)*For each and for each -connected component, in , , component is -connected in .*(3)*There is for which , for all .*(4)*Let the configuration have components , . Let a component be -connected, , . Let . For any black cell , if the cell changes its state to white (), then the obtained component is -connected, where or the obtained configuration has components.*

*Proof of Theorem 1. *Notice, those white cells remain always white ( in Figure 3). From this fact, it follows that CA cannot connect two disconnected components. So, each component can be observed independently and for each component we can assume that its complement has all white cells.

Let be 1-connected component. For the component we will prove that in any time step there are one or more black cells that are transformed in white. Hence, because of finiteness, after some time steps, the component will vanish.

Let be circumscribing rectangle of dimensions for , .

If or , component is “column” or “row” and has two ends which are transformed in white cells according to , , , or from Figure 3.

Suppose that and . If component has a cell with 3 or 4 adjacent white cells, then according to , , , or from Figure 3 this cell is transformed in white.

So, we suppose that all cells have no more than 2 adjacent white cells. Traversing boundary cells in negative direction (component is always on the left side), we create a closed path , , shown in Figure 4(b).

Supose that we observe a time step , where . Denote by and , , the bottom rightest and top rightest cells in the component, respectively. Similar, we can observe time steps , where .

We consider two cases:(1)cells are all different,(2)some of cells are equal.

In case 1, cells , have the neighbourhoods as , from Figure 3. If this is not case, then one of them, for example , has the neighbourhood . Then, the white cell in position surrounded by the path which is in contradiction with is 1-connected (path surrounds a finite hole).

In case 2, there exists a closed path (see Figure 4): in with length , in which all cells are different, except ends. In the closed path , as we already proved in the previous paragraph, there exists a cell with neighbourhood as or from Figure 3.

With this we proved Theorem 1, property 1.

All neighbourhoods from Figure 3 are such that if central cell changes its black state to white, then connectivity of its neighbouring black cells is preserved or “new” central white cell connects already weakly connected neighbouring white cells. So, local transition function of the CA preserves the level of connectivity for each component. With this we proved Theorem 1, property 2.

Because of finiteness of components and deterministic rules, Theorem 1, property 3 is obvious.

Suppose that black cell . We will prove that the cell has at least two white cells in its neighbourhood. So, we can suppose that(1)cell has no neighbouring white cells,(2)cell has one neighbouring white cell.

If we have case 1, then cell is also black ( from Figure 3). Because of symmetry, this holds for cells , , and , also. Further, cell is also black ( or from Figure 3). Because of symmetry, this holds for cells , , , , , , and , also. Continuing, we have that all cells in are black. Because of boundary condition and finiteness, there is a cell which changes its state in the configuration which is in contradiction that is a component in (property 3).

Same consideration holds for case 2.

Now, we will prove that cell has at least two nonweakly connected, in the neighbourhood, white neighbours. Because cell has at least two connected black neighbours ( from Figure 3), we have three cases.(1)Cell has exactly two connected black neighbours. We can suppose that black cells are(a) and or(b) and . In case (a), cell must be white ( from Figure 3). Case (b) is obvious.(2)Cell has exactly three connected black neighbours. We can suppose that the tree black cells are , , and . Then, cells , cannot be black at the same time ( from Figure 3).(3)Cell has exactly four connected black neighbours. This case is obvious.

Hence, in every case we have two white cells in the neighbourhood of the cell which are nonweakly connected, in the neighbourhood.

If these two neighbours are weakly connected in the configuration , then they are from the same hole. Changing state of the cell will increase the number of components in .

If these two neighbours are not weakly connected in the configuration , then they are from different holes. Hence, changing state of the cell will decrease the number of holes in .

**(a)**

**(b)**

Now, we consider the theoretical complexity of the algorithm by means of the required number of time steps. Let be a configuration. Let have components , . Suppose that dimension of circumscribing rectangle of component is , . From the proof of the Theorem 1 we have the following.

Corollary 2. *The worst case complexity of the CA for the configuration is .*

#### 4. Implementation and Experimental Results

Implementations of the algorithm are made in NetLogo 5.0.4 (agent-based programming language and integrated modelling environment). The CA model is represented by 2-dimensional grid of square cells and each cell can exist in two different sates, white or black. Any cell is coloured black with probability and white with probability 1 . These probabilities are independent for every cell. Within an iteration, the whole grid is processed at once; namely, each cell is transformed to a new state without affecting the other cells. After the update, algorithm proceeds to a new iteration. The iteration takes place as long as at least one cell is changed. The global operations in the algorithm are the steady state checking and alternating numbers from . However, here we emphasize that the alternation of numbers from is possible to substitute by randomly choosing a number from . With this we obtain nondeterministic CA with no need for the global operation.

In Figure 5 we present examples of the implementation. In all examples 201 × 201 grid is used. Differences are in generating initial grid. In Figures 5(a), 5(b), and 5(c) random grid with densities 0.55, 0.50, and 0.65 is used, respectively.

**(a) Probability for black cell is 0.55**

**(b) Probability for black cell is 0.60**

**(c) Probability for black cell is 0.65**

#### 5. Conclusions

We proposed a new CA algorithm for thinning with property of preserving -connectivity, , of all components in any random binary grid. Simple definition of used CA has several advantages; for example, CA is not limited by the number of elements, its evolution is inherently parallel, it has a strong resemblance to the important approaches in the nature like principles of cells that are building blocks for large systems or elementary particles, and so forth. However, several drawbacks can also be identified, for example, lack of global communication, which implies problems, related to global synchronization, inability for calculation of complex mathematical operations, and so forth. However, the heterogeneous computing, supported today with data flow approaches, field programmable gate array (FPGA), and graphic processing unit (GPU) systems, systems on chips, are promising platforms for the implementation of the efficient CA algorithms. Finally, further work is also in the investigation of necessary extensions of the algorithm for 3D grids.

#### Conflict of Interests

The authors declare that there is no conflict of interests regarding the publication of this paper.