### Correlated calculation of probabilistic projection graphs

The Camshift tracking method employs the chrominance (H) information in the HSV color space to establish a histogram model of the target [17, 18]. Subsequently, on the basis of the established histogram, an inverse probability projection graph of the target in the tracking window is set up [19, 20]. Since the histogram model is relatively simple to establish in some ways, the computational cost of the tracking method is little [21, 22].

Assume that the chromaticity value in the HSV color space is divided into *m* levels [23], and there are a total of *S* pixels from the target area, where the coordinate position of the *i*th pixel is (*x**i*,*y**i*),*i*=1,2,…,*S*, the corresponding chromaticity value of the point is *b*(*x**i*,*y**i*) [24, 25]. Then, we could achieve the target chromaticity histogram model for the target area by the following formulae.

$$ \begin{aligned} &{\mathbf{q}}= \left\{{q_{u}}\right\},u=1,2,\ldots,m \\ &q_{u}=\sum\limits_{i = 1}^{S} \delta[b(x_{i},y_{i})-u] \end{aligned} $$

(1)

Set the chromaticity value of the pixel at position (*x*,*y*) in the tracking window as *u*. According to the target histogram model by Eq. (1), the value of inverse projection probability at this point can be obtained:

$$ p(x,y)=\frac{q_{u}}{\text{max}\left\lbrace q_{i}|i = {\rm{ }}1,{\rm{ }}2,{\rm{ }}3,{\rm{ }} \ldots,m\right\rbrace } $$

(2)

The pixel gray value represents the probability value, and the projection gray value corresponding to the above inverse probability value is *p*_{g}(*x*,*y*):

$$ {p_{g}(x,y)}=\left\lfloor{{\frac{q_{u}}{\text{max}\left\lbrace q_{i}|i = {\rm{ }}1,{\rm{ }}2,{\rm{ }}3,{\rm{ }} \ldots,m\right\rbrace }}\times255}\right\rfloor $$

(3)

The symbol “ ⌊⌋” signifies rounding. The gray value of inverse probability projection is obtained through Eq. (3) for all pixels within the tracking window, then the inverse probability projection graph could be obtained. The gray value of the pixel in the inverse probability projection graph varies from 0 to 255. Particularly, the pixel with a gray value of 255 appears white, which means that the pixel belongs to the target area in significant measure, and the pixel with a gray value of 0 is black, which indicates the probability that the pixel belongs to the target area is comparatively tiny.

In the above-described target inverse probability projection graph, the correlation information between adjacent pixels is not taken into account only considering the individual information of each pixel. Therefore, when it comes to the chromaticity, if the background is analogous with the target chromaticity, each pixel from background graph will also obtain a higher probability value in the inverse projection graph, which would lead to huge interference to the object identification.

Considering this challenge, there are two ways to deal with, that is, to increase the probability gray value of the target area within the inverse projection graph or to suppress the probability gray value of the background area, respectively. Hence, we propose a chromaticity correlation calculation for the inverse probability projection graph obtained by Eq. (2), that is, each pixel point is associated with the probability value of the surroundings, so as to determine the inverse projection correlation probability value. The distribution of a pixel *a*_{0,0} and its surrounding pixels in the inverse projection graph is depicted in Fig. 1.

In which *a*_{i,j} represents the *j*th pixel around the *i*th circle of *a*_{0,0}, and the probability value calculated by Eq. (2) for this pixel is \( p^{0}_{i,j} \). A correlation calculation is performed on the probability value \( p^{0}_{0,0}\) of the pixel *a*_{0,0} to obtain \(p^{1}_{0,0}\):

$$ {p^{1}_{0,0}} = \frac{1}{N}\left[\sum\limits_{i= 1}^{N}{\frac{1}{8i}{\sum\limits_{j = 1}^{8i} {{p^{0}_{0,0}}.{p^{0}_{i,j}}}}}\right] $$

(4)

According to Eq. (4), the results of multiple correlation calculations can be deduced. For example, the *k*-time correlation results for pixel *a*_{0,0} are:

$$ { p^{k}_{0,0}} = \frac{1}{N}\left[\sum\limits_{i= 1}^{N}{\frac{1}{8i}{\sum\limits_{j = 1}^{8i} {{p^{k-1}_{0,0}}.{p^{k-1}_{i,j}}}}}\right] $$

(5)

Although the probability of the target areas will be suppressed through the formula in (5), but the probability value for the background area will be suppressed more significantly. In this way, we could achieve a good tradeoff among the highlighting for target area and the control for the background area, so that ultimately enable the goal to be more prominent. Next, the obtained probability value by (5) is conducted in the normalization process, and then the inverse projection probability gray value is calculated as follows:

$$ {p_{i,j}}=\left\lfloor \frac{p^{k}_{i,j}}{p^{k}_{\text{max}}}{\times255}\right\rfloor $$

(6)

Among them, \(p^{k}_{\text {max}}\) denotes the maximum probability value in the tracking window after *k*-time correlation calculations, that is \(p^{k}_{\text {max}}= \text {max}\left \lbrace p^{k}_{i,j}\right \rbrace \). The accuracy of the target recognition will be considerably fruitful owing to utilizing the inverse projection probability graph after correlation calculation to identify and locate the target.

### Algorithm description

Specifically, the algorithm for target recognition and tracking is described as follows in detail:

**Step 1.** Select the tracked target and employ the foregoing Eq. (1) to establish the chromaticity histogram model for the tracked target.

**q**={*q*_{u}},*u*=1,2,…,*m*

**Step 2.** Calculating the inverse projection probability value by Eq. (2).

**Step 3.** Searching the k-time correlation probability value through Eq. (5).

**Step 4.** Building the inverse projection probability graph by using Eq. (6).

**Step 5.** Computing the zero and first-order moment for the search window based on the gray value of the inverse probability-based projection graph:

$$ {M_{00}} =\sum\limits_{x}^{} {\sum\limits_{y}^{} {p_{x,y}}} $$

(7)

$$ {M_{10}} =\sum\limits_{x}^{} {\sum\limits_{y}^{}x{p_{x,y}}} $$

(8)

$$ {M_{01}} =\sum\limits_{x}^{} {\sum\limits_{y}^{}y{p_{x,y}}} $$

(9)

**Step 6.** Figuring up the centroid position (*x*_{c},*y*_{c}) of the search window by using the zero and first-order moments obtained in step 5:

$$ {x_{c}} = \frac{M_{10}}{M_{00}} $$

(10)

$$ {y_{c}} = \frac{M_{01}}{M_{00}} $$

(11)

**Step 7.** Adaptively adjust the side length of the search window:

$$ s =2 \sqrt {\frac{M_{00}}{256}} $$

(12)

The center of the search window is drifted to the centroid of the search window. Then, comparing the drift distance with the set threshold, and if the drift distance is greater than the set threshold, we need to repeat steps 5–7 and continue the next step 8 until the drift distance is less than the set threshold.

**Step 8.** Calculating the second-order moment of the search window based on the correlation probability value:

$$ {M_{11}} =\sum\limits_{x}^{} {\sum\limits_{y}^{}xy {p_{x,y}}} $$

(13)

$$ {M_{20}} =\sum\limits_{x}^{} {\sum\limits_{y}^{}x^{2} {p_{x,y}}} $$

(14)

$$ {M_{02}} =\sum\limits_{x}^{} {\sum\limits_{y}^{}y^{2} {p_{x,y}}} $$

(15)

According to the second moment obtained above, the following three parameters are calculated:

$$ a=\frac{M_{20}}{M_{00}}-x^{2}_{c} $$

(16)

$$ b=2\left(\frac{M_{11}}{M_{00}}-{x_{c}}{y_{c}}\right) $$

(17)

$$ c=\frac{M_{02}}{M_{00}}-y^{2}_{c} $$

(18)

Accordingly, on the basis of the obtained parameters, the size and direction of the target area are adaptively updated. Concretely, the length, width, and direction of the target area is updated as in (19), (20), and (21), respectively:

$$ L=\sqrt{\frac{(a+c)+\sqrt{b^{2}+(a-c)^{2}}}{2}} $$

(19)

The width of the target area is updated as:

$$ W=\sqrt{\frac{(a+c)-\sqrt{b^{2}+(a-c)^{2} }}{2}} $$

(20)

The direction of the target area is updated to:

$$ \theta=\frac{1}{2}\operatorname{\arctan\left({\frac{b}{a-c}}\right)} $$

(21)

Until here, the recognition and tracking of this frame are smoothly completed.

**Step 9.** Return to step 1, focus on the next frame, re-identify, locate, and track the target of the next frame by employing steps 1–8.

Through the above series of steps of our proposed *C**a**m**T**r**a**c**o**r*_{−PG}, a model pig could be more effective in tracking and recognizing with better precision in a scalable manner. In the process of described tracking above, the target is recognized and tracked well by means of multi-correlation probability grayscales. Formally, our proposal is specified by the following pseudocode. The performance of our proposal is specified by the following Section 3.