Supposing a THz image *I* of size *H*×*W*, and *I*_{i,j} denotes the intensity value of the pixel at position (*i*,*j*). Let each pixel as a node, the edge detection with the ACA can be executed according to the following four steps: 1) initialization, 2) construction, 3) update, and 4) decision.

The details of the pseudo code are shown in Algorithm 1, as shown in Figure 3.

Figure 3 The pseudo code of the ACA

**Step 1**:At first, set each element of the pheromone matrix *τ*^{(0)} to constant *τ*_{init}.

**Step 2**: Secondly, choose one ant at random among the total *S* ants during the n-th construction step, and let it continuously move *L* movement-steps on the image according to an eight-connected neighborhood. For moving from node (*l*,*m*) to its neighbor node (*i*,*j*), a transition probability is defined by the following formula

$${p}_{(l,m)(i,j)}^{(n)}=\frac{{({\tau}_{i,j}^{(n-1)})}^{\alpha}{({\eta}_{i,j})}^{\theta}}{{\sum}_{(i,j)\in {\mathrm{\Omega}}_{(l,m)}}({({\tau}_{i,j}^{(n-1)})}^{\alpha}{({\eta}_{i,j})}^{\theta})}$$(1)

where ${\tau}_{i,j}^{(n-1)}$
is the pheromone value of the node (*i*,*j*), and Ω_{(l,m)} represents the neighbor node set of the node (*l*,*m*). The impact of pheromone matrix and heuristic matrix are described by constants *α* and *θ*, respectively. The heuristic information of node (*i*,*j*) is denoted by *η*_{i,j} and expressed as

$${\eta}_{ij}=\frac{1}{Z}{V}_{c}({I}_{i,j})$$(2)

in which, $Z=\sum {}_{i=1:{M}_{1}}\sum {}_{j=1:{M}_{2}}{V}_{c}({I}_{i,j})$ is a normalization factor. The relationship of pixels *c* in local region (called the \textit{clique\textit}) can be described by a function *V*_{c}(*I*_{i,j}) and its value is decided by the intensity deviations of *c*. For example, it can be defined as

$$\begin{array}{rl}{V}_{c}({I}_{i,j})& =f(|{I}_{i-2,j-1}-{I}_{i+2,j+1}|\\ & +|{I}_{i-2,j+1}-{I}_{i+2,j-1}|+|{I}_{i-1,j-2}-{I}_{i+1,j+2}|\\ & +|{I}_{i-1,j-1}-{I}_{i+1,j+1}|+|{I}_{i-1,j}-{I}_{i+1,j}|\\ & +|{I}_{i-1,j+1}-{I}_{i-1,j-1}|+|{I}_{i-1,j+2}-{I}_{i+1,j-2}|\\ & +|{I}_{i,j-1}-{I}_{i,j+1}|)\end{array}$$(3)

Here we adopt a parameter *σ* to adjusts the functions’ respective shapes and the function *f*(.) in Eq.(3) can be determined as

$$\begin{array}{r}f(x)=\left\{\begin{array}{ll}\frac{\pi x\mathrm{sin}(\frac{\pi x}{\sigma})}{\sigma}& 0\le x\le \sigma ;\\ 0& else\end{array}\right..\end{array}$$(4)

Step Thirdly, two update operations are performed for the pheromone matrix. The first one is conducted when every ant finishes its movement during each construction step and given as

$$\begin{array}{r}{\tau}_{i,j}^{(n-1)}=\left\{\begin{array}{ll}(1-\rho ){\tau}_{i,j}^{(n-1)}+\rho {\mathrm{\Delta}}_{i,j}^{(k)},& otherwise.\\ {\tau}_{i,j}^{(n-1)},& (i,j)\phantom{\rule{thickmathspace}{0ex}}is\phantom{\rule{thickmathspace}{0ex}}not\phantom{\rule{thickmathspace}{0ex}}visit\phantom{\rule{thickmathspace}{0ex}}by\\ & {k}^{th}\phantom{\rule{thickmathspace}{0ex}}ant\end{array}\right.\end{array}$$(5)

where *ρ* represents the evaporative rate, and ${\mathrm{\Delta}}_{i,j}^{(k)}$ is decided by the heuristic matrix ${\mathrm{\Delta}}_{i,j}^{(k)}={\eta}_{i,j}$.

The other is performed while all ants complete their movements among every construction step and is defined as

$${\tau}^{(n)}=(1-\psi )\cdot {\tau}^{(n-1)}+\psi \cdot {\tau}^{(0)}$$(6)

in which, *ψ* denotes the pheromone decay coefficient.

**Step 4**: Then the ant movement operation has been run for *S* iterations in order to build the ultimate pheromone matrix *τ*^{(S)} by iteratively executing step 2 and step 3.

**Step 5**: Finally, to obtain the edge, a decision-making process based on threshold *T* is carried out according to the following equation

$${T}^{(l)}=\frac{{m}_{L}^{(l)}+{m}_{U}^{(l)}}{2}$$(7)

The threshold *T* can be gained by the following operations: Let the mean of *τ*^{(S)} as the initial threshold *T*^{(0)} and divide *τ*^{(S)} into two classes by the criterion of lower or upper than *T*^{(0)}, then compute the new threshold based on Eq.(4) until its value maintains unchanged.

## Comments (0)

General note:By using the comment function on degruyter.com you agree to our Privacy Statement. A respectful treatment of one another is important to us. Therefore we would like to draw your attention to our House Rules.