This paper proposes a novel method of group-housed pigs recognition based on WTLD. The framework is illustrated in

Figure 1. Firstly, the top-view videos of group-housed pigs are collected. Secondly, the videos are divided into image frames. After image enhancement and segmentation, images of individual pigs are obtained. Then, the local features of pigs are extracted based on WTLD. Finally, support vector machine (SVM) classifier is used for training and recognition.

#### 2.2. Weber Local Descriptor (WLD)

Psychologists have observed that the ratio of the intensity change of an object after being stimulated to its original intensity is a constant—that is, the ratio of the increasement Δ

I to original intensity

I is a constant

k. This relationship is called Weber Law [

25], as following:

Inspired by this, Weber local descriptor (WLD) [

26] calculates the intensity difference between a central pixel and other pixels in its neighborhood. The differential excitation is used to describe the local significant pattern in the image, as shown in Equation (2):

where

ξ denotes the differential excitation,

x_{c} is the central pixel,

x_{i} is the

ith pixel in the neighborhood of

x_{c}, and

p represents the number of pixels in the neighborhood.

${v}_{s}^{00}$ and

${v}_{s}^{01}$ are the output of differential excitation filters

f_{00} and

f_{01}, respectively. Then,

ξ is evenly divided into

M bands. Each band is uniformly quantized into

S intervals.

In addition to the differential excitation, the gradient direction of the pixel is also calculated in WLD. The ratio of horizontal and vertical gray gradient is used to describe the local direction information in the image, as shown in Equation (3):

where

θ denotes the direction, while

${v}_{s}^{11}$ and

${v}_{s}^{10}$ represent the output of horizontal and vertical filters

f_{10} and

f_{11}, respectively. Then,

θ is quantized into

T directions after interval transformation. Finally, a two-dimensional histogram of

T × (

M ×

S) is constructed, where the abscissa is the direction and the ordinate is the differential excitation. Then, the two-dimensional histogram is concatenated into a one-dimensional histogram.

#### 2.3. Weber Texture Local Descriptor (WTLD)

Although WLD computes the differential excitation and direction, only the horizontal and vertical local directions are considered, and the local structure information could not be fully expressed. In order to solve these problems, this paper proposes a Weber texture local descriptor, which not only combines multi-directional information with the differential excitation, but also contains the principal local structure information. Therefore, WTLD extracts more discriminative and powerful features than WLD. The WTLD computation is shown in

Figure 4.

The calculation method of the proposed WTLD is as follows:

- 1.
The differential excitation of each pixel is calculated by:

where

x_{c} represents the center pixel value,

x_{i} denotes the value of the

ith pixel in the neighborhood, and

p is the number of pixels in the neighborhood.

Figure 5 shows pixel and its eight neighborhoods. Then, the differential excitation

γ is evenly divided into

M bands and each band is quantized into

S intervals.

- 2.
In order to extract the local multi-directional information, the multi-directional masks are used. The original image is convoluted with the multi-directional masks, as shown in Equation (5):

where

I represents the original image,

M_{i} denotes the multi-directional mask in the

ith direction.

R_{i} is the absolute value of the filtering result in the

ith direction.

Figure 6 shows Kirsch compass masks in 8 directions.

After convoluting with multi-directional masks, the response values in multiple directions are obtained. Then, the absolute values of the directional responses are calculated. The main direction of the neighborhood, such as the maximum direction, is defined by:

where

D_{1} denotes the maximum directional number. In the similar way, we can obtain the second, third, and fourth maximum directional numbers:

D_{2},

D_{3}, and

D_{4}. After that, the two-dimensional histogram of

T × (

M ×

S) is constructed and connected in series to form a one-dimensional histogram.

Figure 7 shows the directional images of WLD and the proposed WTLD.

Figure 7a are original RGB images of individual pigs.

Figure 7b are the gray images of the original images.

Figure 7c are directional images of WLD, which are calculated by horizontal and vertical filtering.

Figure 7d are directional images of WTLD. Kirsch masks are used for multi-directional filtering, and the maximum direction number is used for directional images. As can be seen from

Figure 7b, the hair, skin texture, and spots on a pig’s body that are different from each other can be used for distinguishing different individuals. By comparing

Figure 7c,d, it can be seen that the directional images obtained by WTLD provide more detailed local information on the pig body surface. Obvious light and shade changes can be seen in many local areas. The red squares indicate some areas, but they are not limited to these areas.

In order to verify the effectiveness of the multi-directional information of the WTLD, the correlation coefficients of directional images were calculated for 10 pigs. The definition of the correlation coefficient is as follows:

where

A and

E are images,

m and

n are the size of the image, and

Ā and

Ē represent the mean values of

A and

E.

Figure 8 shows the correlation coefficient matrix of directional images based on WLD and WTLD.

Figure 8a is the correlation coefficient matrix of the directional images based on WLD, and

Figure 8b is the correlation coefficient matrix of the directional images based on WTLD. As can be seen from the results, the correlation coefficients of different individual images based on WLD were relatively large; all the coefficients are more than 0.988. Conversely, the difference between pixels becomes larger due to the consideration of the multi-directional response of each pixel in the WTLD method. Hence, the correlation coefficient between different pig images is reduced. It indicates that multi-directional information can provide more discriminative information, which is helpful to distinguish different pig individuals.

- 3.
The difference excitation of the original WLD only calculates the difference between the central pixel and its neighborhood. Intensity variations of pixels in the neighborhood are not considered, which resulting in an insufficient expression of local structural information. To solve this problem, the gray intensity difference between pixels in the main direction is calculated, as shown in Equation (8):

where

C_{i} is the intensity difference of pixels. The calculation of intensity difference in the main direction not only describes the maximum direction of pixel change in the neighborhood, but also distinguishes the size of the change.

Since the grayscale values can be of any size, it is necessary to quantify them for coding. Therefore, an adaptive threshold σ is adopted such that the average absolute value of the gray intensity difference in different directions are taken as the threshold, as shown in Equation (9):

where,

In Equation (9),

M_{i} is the encode value of the intensity difference and

N is 4. Then, the main direction number

D_{1} and local structure information

M_{1} are encoded, as shown in Equation (10):

Finally, the image is divided into sub-blocks of the same size, and the local intensity histogram is calculated. The differential excitation and direction histogram are cascaded with the local intensity histogram to form a feature vector.

Figure 9 shows the local structure information coding process. As can be seen from

Figure 9b,c, the main directional images reflect details such as the muscle concavity and convex, body surface patches, and so on. The intensity difference images describe more local skin texture formed by the hair. They all provide effective information to distinguish different individuals.