# A Review of Posture Detection Methods for Pigs Using Deep Learning
## 2 Data Acquisition and Sub-Tasks for Pig Posture Detection
### Sub-Tasks for Image-Based Pig Posture Detection
#### 2.2.3 Pig Segmentation  
Pig segmentation divides the pixels of an image into two subsets of foreground targets and background areas and generates pig segmentation masks [37], as Figure 5a shows. In traditional image processing, segmentation to obtain pig contours is used for localization prior to posture classification, which may affect the performance of pig classification since the quality of feature extraction of pigs is primarily determined by the effectiveness of pig segmentation [6]. In a previous study, by adopting the Otsu  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Posture Type** & **Description** & **Reference** \\ \hline \begin{tabular}{c} Sternal recumbency/Lying on \\ belly/Sternal lying/Lying on the \\ stomach/Prone \\ \end{tabular} & \begin{tabular}{c} Lying on abdomen/sternum with front \\ and hind legs folded under the body; \\ udder is totally obscured \\ \end{tabular} & [7; 29; 55; 56; 57] \\ \hline \begin{tabular}{c} Lateral recumbency/Lying on \\ side/Lateral lying/Sidling \\ \end{tabular} & \begin{tabular}{c} Lying on either side with all four legs \\ visible (right side, left side); udder is \\ totally visible \\ \end{tabular} & [7; 29; 55; 57] \\ \hline \begin{tabular}{c} Sitting \\ \end{tabular} & \begin{tabular}{c} Partly erected on stretched front legs with \\ caudal end of body contacting the floor \\ \end{tabular} & [29] \\ \hline \begin{tabular}{c} Mounting \\ \end{tabular} & \begin{tabular}{c} Stretch the hind legs and standing on the \\ floor with the front legs in contact with \\ the body of another pig \\ \end{tabular} & [55] \\ \hline \
\begin{tabular}{c} Exploring \\ \end{tabular} &
\begin{tabular}{c} The pig’s snout approached or nosed a \\ part of the pen for more than 2 s. This \\ was differentiated depending on the \\ objects, such as a wall (including a fence \\ door) or the floor \\ \end{tabular} & [42; 58] \\ \hline \hline \end{tabular}
\end{table}
Table 1: _Cont._adaptive threshold segmentation algorithm followed by canny edge detection and using morphological algorithms, normalized binary contour images of every pig were extracted for the classification of four kinds of behavioral postures of pigs [41]. Similar to threshold segmentation, watershed transformation can also separate the boundary of each pig from the background under commercial farm conditions for the detection of lateral and sternal lying postures [7].  
In the deep learning field, segmentation technology always plays an assisting role rather than serves as an essential condition for pig posture detection; it can also accelerate the detection process and enhance the accuracy by providing rich information for subsequent processes under certain circumstances [62; 63]. By integrating an advanced semantic-segmentation model DeepLabv3+ [64] into a pig posture detector, more contextual information can be obtained, which can greatly improve the feature extraction by the base network [42]. In a previous study [37], a panoptic segmentation combining semantic segmentation and instance segmentation can provide pig information with pixel-level accuracy for posture recognition, which can overcome the disadvantage of gross bounding boxes and sparse key points.