Next Article in Journal
The Impact of the Integration of Digital and Real Economies on Agricultural New Quality Productive Forces: Empirical Evidence from China’s Major Grain-Producing Areas
Previous Article in Journal
Evaluation of Sensor-Based Soil EC Responses to Nitrogen and Potassium Fertilization Under Laboratory and Field Conditions
error_outline You can access the new MDPI.com website here. Explore and share your feedback with us.
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Research on Estimating Backfat Thickness in Jinfen White Pigs Using Deep Learning and Image Processing

1
College of Agricultural Engineering, Shanxi Agricultural University, Taigu 030801, China
2
Dryland Farm Machinery Key Technology and Equipment Key Laboratory of Shanxi Province, Jinzhong 030801, China
*
Author to whom correspondence should be addressed.
Agriculture 2026, 16(2), 138; https://doi.org/10.3390/agriculture16020138
Submission received: 28 October 2025 / Revised: 29 December 2025 / Accepted: 3 January 2026 / Published: 6 January 2026
(This article belongs to the Section Farm Animal Production)

Abstract

To address the time-consuming, labor-intensive, and inefficient nature of existing contact-based measurements of sow backfat thickness (BFT), in this study, a method to estimate BFT from depth images using deep learning and image processing is proposed. Measurements of BFT and hip depth images were collected from 254 Jinfen White sows. Following preprocessing, including depth-value filtering and colorization, a modified YOLOv8n-ShuffleNetV2 detector was trained and deployed to predict regions of interest in the buttock images. Depth values were then extracted from these regions and converted into distance estimates. Then, 11 external morphological pixel-based parameters were extracted, including hip area, hip-circumference length, and the area of the fitted ellipse. A random sample of 203 sows was selected for training and testing, and the relationship between BFT and the external morphological parameters was analyzed in 152, with the rest being used for testing. The results show significant positive correlations between BFT and several hip morphological parameters, with Pearson correlation coefficients exceeding 0.90 for both hip and fitted ellipse area. Principal component analysis was applied to the selected hip features to extract area and length related factors as inputs to a machine learning model. An elastic net regression model was employed to estimate BFT. The model’s generalization capability was evaluated using 51 sows not involved in training and testing. The model achieved an R2 = 0.8617, MSE = 4.3626 mm2, and MAE = 1.6456 mm. Finally, a BFT estimation system for Jinfen White pigs was developed using PyQt5 and Python, which enables automatic preprocessing of sow hip images and real-time estimation of BFT. Together, these results address the cumbersome and inefficient traditional manual collection of sow BFT data and support precision management in sow breeding farms.

1. Introduction

The reproductive performance and productive lifespan of sows are key determinants of the economic efficiency of sow production [1], and backfat is significantly correlated with these factors. This layer of subcutaneous adipose tissue along the sow’s back provides energy for daily activities and secretes numerous bioactive substances [2]. An optimal range of backfat thickness (BFT) positively influences key reproductive processes in sows, including estrus, conception, gestation, and lactation. In multiparous sows, maintaining appropriate BFT across reproductive stages supports normal reproductive hormone secretion and sustains optimal reproductive function, yielding consistent and stable reproductive performance [3]. Maintaining adequate backfat after weaning also facilitates the faster resumption of estrus, shortens the weaning-to-estrus interval, and improves reproductive efficiency. Therefore, dynamic monitoring of BFT in sows is crucial for improving reproductive performance and overall swine production [4].
Currently, measurement of BFT in sows primarily relies on three methods, namely visual palpation, ultrasound measurement [5], and CT scanning [6]. These measurement methods are labor-intensive, inefficient, and prone to measurement inaccuracies; moreover, they do not meet the need for automated, dynamic monitoring of BFT in pregnant sows at commercial farms, thereby limiting monitoring efficiency. With ongoing advances in deep learning (DL) and image processing [7], non-contact rapid measurement methods for assessing sow body condition have emerged as a promising direction in intelligent pig farming. Current non-contact estimation of BFT in pigs predominantly uses end-to-end DL approaches. These methods input pig images directly into neural networks and output predicted BFT [8]. Yu et al. created a CNN-BGR-SVR model based on 2D images of sow backs, using BFT measurements for pregnant sows via backfat-derived blue-green-red features [9]. Li et al. proposed a sow BFT measurement method based on a hybrid CNN–ViT model capable of simultaneously extracting local and global image features, although the effectiveness of their approach was limited by dataset availability [10]. Nevertheless, images captured in real production environments are affected by factors such as uneven indoor lighting, random pig movements, pen obstructions, and nonstandard standing postures, all of which can degrade prediction accuracy, so feeding such raw images directly into models compromises the accuracy of BFT predictions.
Concurrently, some researchers have explored relationships between sow BFT and external morphological parameters, offering new avenues for non-contact measurement. Teng et al. extracted curvature-radius features from the sow’s buttocks using point cloud processing, revealing a significant correlation with BFT, which demonstrates the feasibility of this non-contact BFT estimation technique [11]. Zhang et al. analyzed correlations between hip morphology and BFT using machine vision, creating a multi-feature fusion model for BFT estimation [12]. Research on computer vision-based pig body condition scoring began relatively late [13], whereas non-contact body condition estimation is more prevalent in cattle and sheep. Alvarez et al. developed an end-to-end CNN to directly estimate bovine body condition from depth maps, contour edges, and Fourier-transformed images, addressing limitations of manually-defined features [14]. Azzaro et al. proposed a bovine body model using a digital imager for objective, semi-automated body condition scoring [15], while Vieira et al. investigated goat body condition scoring methods using standard template matching [16]. These studies advanced animal condition estimation, but their accuracy remains difficult to guarantee due to limitations in feature extraction precision. Additionally, these models often suffer from limited interpretability due to the opaque (black-box) nature of the associated decision-making process.
To address the limitations of existing non-contact methods for estimating sow BFT, including insufficient accuracy and interpretability, and the drawbacks of traditional contact measurements, such as stress risks and inefficiency, in this study, a non-contact BFT estimation method for sows is presented based on DL and image processing. The pro-posed approach seeks to enhance estimation accuracy and, at the same time, ensure suitability for practical farming applications. The core methodology is illustrated in Figure 1. Specifically, a DL object detection model accurately locates the critical region of interest (ROI) on the sow’s rump. External morphological features correlated with BFT are then extracted using image processing techniques. An efficient estimation model is then created and integrated into an auto-mated estimation system based on the analysis of the intrinsic relationship between these morphological features and BFT. The developed system enables non-contact measurement, avoiding the stress and injury caused by direct physical contact with the pig, while at the same time enabling rapid batch detection, thus significantly enhancing inspection efficiency in large-scale farming scenarios. Furthermore, subjective interference from manual measurements is reduced, ensuring the accuracy and reliability of estimation results. Ultimately, the proposed method provides accurate data support for optimizing sow feeding management plans in pig farming enterprises, contributing to the industry’s advancement toward precision and sustainability.

2. Materials and Methods

2.1. Data Set Acquisition

2.1.1. Acquisition of Sow Buttocks Images

Images of sow buttocks were acquired at a pig farm in Jinzhong City, Shanxi Province, from 14 February to 15 March 2025. The image acquisition system used to capture depth and RGB images of sow buttocks comprised a laptop computer, a depth camera (Azure Kinect DK, Microsoft, Redmond, WA, USA), and a camera mount. As shown in Figure 2a,b, during image acquisition, the depth camera was positioned 100 cm above the ground and parallel to the pen behind the pigs, to prevent rear fencing from obstructing the imaging process. A total of 2640 depth images from 254 Jinfen White sows were collected for the experiment.

2.1.2. Data Acquisition for Backfat Thickness in Sows

BFT measurements in sows were collected during the feeding period. BFT was measured with an ultrasound monitor (Pig Doctor) under the supervision of a veterinarian. Measurements associated with swine production were obtained from the internationally recognized P2 location [17], defined as 6–8 cm lateral to the midline at the outer tangent of the last rib. A total of 254 sows were measured, comprising 178 gilts and 76 parous sows. The distribution across BFT categories (5–10, 11–15, 16–20, 21–25, 26–30 mm) was 35, 75, 76, 38, and 30 sows, respectively.

2.1.3. Image Preprocessing

First, depth-value filtering was applied to the original image. Taking into account the pig’s body length and position in the image, the minimum and maximum effective depth values were set to 300 mm and 1400 mm, respectively. Pixels within this range were retained, while those outside the range were set to zero. Subsequently, the filtered image was normalized and colorized to unify the depth-value range and reduce filtering-induced variations. To enhance data diversity and reduce overfitting, for example, adding noise to simulate low-quality, noisy images caused by insufficient lighting. Figure 3 shows data augmentation using flipping, mirroring, and Gaussian noise was adopted to expand the dataset from 2640 color-depth images to 13,200 images. Manual annotation of the sows’ buttocks in the images using LabelImg, with a single category set to ‘buttocks’. The dataset was randomly split into test, training, and validation sets at a 1:8:1 ratio.
Depth images of the sow’s buttocks showed distance-dependent color characteristics at different rear-view distances, as illustrated in Figure 4. These color differences allowed the buttocks to be distinguished from surrounding environmental objects. Accordingly, the buttocks region within the sow’s depth image was defined as the ROI for extracting external morphological parameters of the buttocks.
Variations in sow body length and standing posture during feeding caused the hip-to-depth-camera distance to fluctuate during image acquisition. These fluctuations distorted the contour dimensions of the images and compromised the accuracy of the extracted external morphological parameters. To mitigate this effect, the hip-to-depth-camera distance for all hip ROIs was measured and 1000 mm was adopted as the reference distance. The length and area calculations are given in Equations (1)–(3) below.
K = D S D R
L = L P × K
A = A P × K 2
where DS is the sampling depth; DR is the reference depth distance, with a value of 1000 mm; K is the depth ratio coefficient; L is the conversion length; LP is pixel length; A is the conversion area; AP is pixel area.

2.2. Improved YOLOv8n-ShuffleNetV2 Algorithm for Detection of Sows’ Buttocks Regions of Interest

To extract the buttocks ROI from sow depth images accurately, we employed an object detection approach for automatic ROI acquisition. Figure 5a shows the YOLOv8 network architecture, which incorporates several optimizations over YOLOv5 [18], yielding higher detection performance and efficiency. Its backbone uses CSPDarknet-53, comprising the CBS, C2f, and SPPF modules. Specifically, CBS performs convolution, batch normalization, and SiLU activation; the C2f module integrates concepts from C3 and ELAN and introduces a gradient-splitting mechanism to enhance feature flow; and SPPF accelerates training while preserving spatial pyramid pooling performance [19]. Different versions of YoloV8 represent scaled variants based on the same architecture. Among these, the n model is the lightest, offering the fastest inference speed and lowest latency, making it suitable for resource-constrained scenarios like embedded systems. The s, m, l, and x models increase in scale progressively and achieve higher accuracy, but their inference speeds decrease significantly. Given the limited computational resources of pig-farm inspection robots, we selected the YOLOv8n variant, i.e., the lightest model, as the baseline.
Figure 6 shows the basic architecture of ShuffleNetV2. Designed as a lightweight network for mobile devices, ShuffleNetV2 comprises basic and down sampling blocks [20]. In a basic block, the input is split into two branches. One branch performs an identity mapping, while the other applies a sequence of convolutions. To promote inter-channel information exchange, the outputs are concatenated and subjected to channel shuffling. The down sampling block omits the channel-splitting operation. Both branches perform down sampling and adjust channel numbers via convolutional layers, so concatenating the branches reduces spatial resolution by half and doubles the number of channels, balancing efficiency with representational capacity.
In object detection tasks, the YOLOv8 backbone enables efficient feature extraction through components such as the C2f module, SPPF, and its convolutional layers. However, while the C2f module enhances feature representation, it also increases the model’s parameter count and computational burden, leading to slower inference speeds and potentially degraded performance during deployment. To address these issues and make the model suitable for deployment on pig barn inspection robots, in this study, a ShuffleNetV2-based backbone is introduced to replace the YOLOv8 backbone, achieving a more lightweight model [21]. which is both accurate and efficient. The modified architecture is shown in Figure 5b.

2.3. Depth Image Processing and Extraction of External Shape Parameters

After obtaining the buttocks ROI coordinates of the sows to be detected by the YOLOv8n-ShuffleNetV2 object detection algorithm, the images were further processed according to the workflow shown in Figure 7. First, the ROI images were subjected to morphological operations, including mean filtering, binarization, and opening. This reduced the influence of pen structures and environmental noise on the extraction of the sow’s buttocks projection area. Variations in the sow’s stance led to differences in the size and shape of the leg images. Moreover, the pig pen’s slatted flooring adjoined the leg imaging area, further complicating the extraction of the true contour of the sow’s buttocks. To mitigate this interference, horizontal lines were drawn sequentially from the top downward across the sow’s contour image. For each horizontal line, the number of intersections with the sow’s contour region was counted. The first horizontal line that yielded more than four intersections was selected; the region below this line was designated as the leg region, and only the area above the line was retained. Subsequently, the center point (centroid) of the processed, binarized image of the sow’s buttocks was extracted. Using this center point as the center of an ellipse, an ellipse fit was performed on the edge pixels of the sow’s buttocks. Finally, a circle fit was performed using the same center point as the center.
For the purposes of this study, 11 external morphological parameters were extracted, namely the buttock pixel area (AB), the fitted ellipse pixel area (AFE), the minimum bounding rectangle pixel area (AR), the buttock contour perimeter pixel length (PB), the major and minor axis lengths of the fitted ellipse (MAE and MIE, respectively), the radius of fitted circle (RC), the pixel hip width (HB), pixel hip height (HH), circularity (CB), and ovality (OB).

2.4. Model Development and Evaluation

A random sample of 203 sows was selected, and a stratified random sampling strategy was employed to divide the dataset into a training set (152 sows) and a test set (51 sows), with the corresponding statistical values shown in Table 1. Correlation analysis between BFT and the 11 parameters for the 152 training sows was conducted using SPSS Statistics Version 26.0, with multicollinearity assessed via the variance inflation factor (VIF). Subsequently, principal component analysis (PCA) was applied to reduce the dimensionality of the sows’ external morphological parameters. The resulting principal components were then used as inputs for both linear and machine learning (ML) models.

2.4.1. Machine Learning Model Creation and Optimization Algorithms

In this study, five widely used ML methods, namely gradient-boosting decision trees (GBDTs), extreme gradient boosting (XGBoost), random forests (RF), elastic net regression (EN), and support vector machines (SVM), were employed to build a model for estimating sow BFT. These methods have broad applicability and demonstrated effectiveness in bioinformatics and related estimation tasks, and are able to capture the relationships and complex patterns between external morphometric parameters and BFT.
Among the five models, GBDTs are an effective ensemble learning method which reduces residuals progressively through sequential training of decision trees, continuously improving predictive accuracy [22]. XGBoost is an enhanced boosting algorithm built upon GBDT, which iteratively adds decision trees, with each new tree learning and fitting the residuals from the previous prediction round, thereby continuously improving model performance [23]. RFs improve model stability and predictive power by aggregating predictions from multiple decision trees, and are widely applicable to classification, regression, and feature selection [24]. EN regression combines ridge and lasso penalties through its adjustment of the regularization strength λ and the mixing parameter α, thereby improving model performance [25]. As a classic supervised learning algorithm, SVM excels at handling nonlinear data and demonstrates outstanding performance in both classification and regression tasks [26].
In ML, hyperparameters are predefined values set before training, and are distinct from model parameters learned from data. They influence the training process and significantly affect model performance and generalization. In this study, Bayesian optimization (BO) was used to tune the hyperparameters of the ML models [27].

2.4.2. Model Evaluation

To evaluate the model’s generalization performance, the coefficient of determination (R2), mean absolute error (MAE), and mean squared error (MSE) were employed. The calculation equations for these metrics are shown in Equations (4)–(6).
R 2 = 1 i = 1 n ( y i y ^ i ) 2 i = 1 n ( y i y ¯ ) 2
M A E = 1 n i = 1 n y ^ i y i
M S E = 1 n i = 1 n ( y ^ i y i ) 2
where yi and y ^ i are the measured and estimated BFT values for sow i; and n is the total number of sows used to validate the model.

3. Results and Analysis

3.1. Performance Comparison of Different Models

In Table 2, the performance of the lightweight YOLOv8n-ShuffleNetV2 model is compared with other scaled YOLOv8 models across five dimensions: trainable parameters, model size, training time, mAP50-95 and inference latency. The results show that the YOLOv8n model, redesigned for lightweight efficiency using ShuffleNetV2, achieves a favorable balance across multiple metrics. With only 2.79 MB of parameters and a model size of 5.6 MB, it is substantially smaller than YOLOv8s, YOLOv8m, and YOLOv8l, while also outperforming the baseline YOLOv8n. In terms of detection accuracy, its mAP50-95 is 94.2%, matching the best-performing YOLOv8m and surpassing YOLOv8n and YOLOv8l. Meanwhile, its single-image processing time is only 3.7 ms, demonstrating that the lightweight design enhances feature extraction through efficient feature interaction and channel shuffle mechanisms. This results in improved recognition accuracy without sacrificing inference speed, enabling real-time video frame and batch detection. The training time was 5.8 h, indicating high training efficiency.
Figure 8a,b illustrates the convergence performance of YOLOv8n-ShuffleNetV2. During training, the loss decreased rapidly in the initial phase and stabilized after about 200 iterations, with no evidence of overfitting or underfitting. All evaluation metrics improved rapidly with only minor fluctuations, indicating strong convergence and training stability. Overall, YOLOv8n-ShuffleNetV2 achieved high recognition accuracy with low resource consumption, so it is well-suited for deployment on embedded platforms, including pig farm inspection robots. The model has reduced computational complexity and cost while maintaining high detection accuracy for sow buttock ROIs.

3.2. Correlation and Principal Component Analysis

Figure 9 shows the heatmap of the Pearson correlation coefficients between sow BFT and various external morphological parameters. BFT exhibits the highest correlation with parameters reflecting hip area, followed by those reflecting hip length, while correlations with other parameters are significantly lower. Specifically, the correlation coefficients between BFT and parameters such as AB, AFE, and AR all exceeded 0.90. The coefficients for PB, MAE, MIE, RC, HB, and HH ranged between 0.70 and 0.89, while the correlations between CB and OB and BFT were weak, with coefficients approaching zero.
Correlation analysis showed that ovality and circularity had only weak correlations with BFT. To avoid degrading the sow BFT estimation model, these variables were removed. Subsequently, we assessed multicollinearity using VIFs for the remaining nine external morphology parameters. The results showed that all VIF values exceeded 10, indicating substantial multicollinearity. Consequently, PCA was applied to reduce these nine parameters to two principal components (see Table 3), thus mitigating multicollinearity effectively. Together, these two components explained 92.74% of the variance in the original data, indicating effective dimensionality reduction.
The cumulative contribution rate of the two principal components reached 92.74%, with principal component 1 (F1) having the highest contribution rate at 74.50%. Table 3 displays the loadings of each indicator on F1 and F2. It can be observed that all loadings for F1 were positive and relatively high, ranging from 0.2962 to 0.3843. Among these, AB, AFE, and AR exhibited the highest loadings at 0.3843, 0.3842, and 0.3821, respectively. This indicates that F1 exerted the greatest influence on sow BFT and represents a comprehensive principal component. Furthermore, correlation analysis results (Figure 9) reveal that all nine external parameters exhibited highly significant positive correlations with BFT. Therefore, F1 was designated as the Area Factor.
Compared to F1, F2 exhibited significant positive and negative differences in load coefficients. Among these, HB, MIE, and RC demonstrated higher positive loads at 0.6515, 0.4347, and 0.3781, respectively, while HH and MAE exhibited higher negative loads at −0.3498 and −0.3373, respectively. Given that these parameters correlate with length attributes and exhibited significantly higher absolute load values than other indicators, F2 was designated as the length factor. The calculation equations for F1 and F2 are provided in Equations (7) and (8).
F 1 = 0.3654 X 1 + 0.3649 X 2 + 0.3635 X 3 + 0.3165 X 4 + 0.2946 X 5   + 0.3516 X 6 + 0.3078 X 7 + 0.3049 X 8 + 0.3209 X 9
F 2 = 0.0946 X 1 + 0.0759 X 2 + 0.0759 X 3 0.4112 X 4 + 0.4928 X 5   + 0.0325 X 6 0.4333 X 7 + 0.4703 X 8 0.3945 X 9

3.3. Sow Backfat Thickness Estimation Model

The two principal components, i.e., the Area Factor and the Length Factor, were used as input features for the ML model. Bayesian optimization was used to explore predefined parameter configurations systematically and identify the optimal settings. The coefficient of determination (R2) served as the performance metric, allowing the evaluation of each parameter configuration to identify the optimal settings for each model. Table 4 reports the optimized parameters for each model, with all other parameters left at their default values.
Scikit-learn (Python 3.9) was used to create and train a BFT estimation model for Jinfen White pigs, employing five ML models: GBDT, XGBoost, RF, EN, and SVM. Table 5 shows the model evaluation results. The EN regression yielded the highest predictive performance (R2 = 0.8356) with MSE = 5.2126 mm2 and MAE = 1.8102 mm. It ranked highest across all metrics on the test set. The SVM model also performed well, with R2 = 0.8208 and relatively low RMSE and MAE. GBDT and XGBoost showed strong test-set performance, with R2 values of 0.9237 and 0.9293, respectively, and low MSE and MAE. However, they exhibited severe overfitting on the test set.
To evaluate the model’s generalization performance, validation was conducted using data from an additional 51 sows not included in the training and test sets. Figure 10 illustrates the comparison between the ML models’ predicted and actual BFT. Validation results further confirm the excellent performance of the EN regression model. The validation-set R2 for the EN model reached 0.86, the highest among models, with a MAE of 1.6456 mm. Data points clustered closely around the fitted line with minimal dispersion, indicating high accuracy and reliability. The F-statistic was 135.96 (p < 0.01), indicating statistical significance of the model. Based on the full training and validation results, the EN model demonstrated superior predictive accuracy, stability, and goodness of fit. Thus, the EN model was selected as the optimal estimator for sow BFT in subsequent analyses.
Using the optimal model described above, a sow BFT estimation model was constructed based on F1 and F2, as shown in Equation (9):
B F T = 17.6588 + 1.9485 F 1 + 0.4114 F 2 0.0446 F 1 2 + 0.1076 F 1 F 2 0.1430 F 2 2

3.4. Sow Backfat Thickness Estimation System

As shown in Figure 11, a system to estimate sow BFT was developed using PyQt5 (5.15.9) and Python (3.9.16). The software leverages built-in Python nodes and image-processing modules to streamline development. When a sow hip image is provided, the system automatically performs the sequence of preprocessing steps described in Section 2.3, which includes depth-value filtering, color normalization, object detection, binarization, morphological opening, removal of the leg region, ellipse fitting, and inscribed-circle fitting. These steps allow the extraction of the parameters needed for BFT estimation, including the hip area, the area of the fitted ellipse, the area of the minimum bounding rectangle, and the hip contour perimeter length in pixels. The system allows real-time estimation of sow BFT with no manual intervention.

4. Discussion

In this study, the limitations of traditional contact-based ultrasound measurements for sow BFT, which rely on manual operation, induce stress in sows, and are inefficient, are addressed. Additional issues addressed include those of non-contact models’ lack of sufficient estimation accuracy due to imprecise feature extraction and the “black box” nature of model decision-making processes, which lack interpretability. An integrated solution is proposed, which combines deep image fusion, DL, and image processing. Compared with traditional RGB images, which capture only two-dimensional texture information and are sensitive to lighting conditions, depth images reflect the 3D structure directly and capture the intrinsic relationship between a sow’s hip morphology and BFT better.
By creating an improved YOLOv8n–ShuffleNetV2 lightweight architecture for the object-detection network to localize hip ROI regions, YOLOv8n’s advantages of high detection speed and reduced computational costs are retained. Using this model, 11 external morphological parameters were extracted, including the buttock pixel area and the area of the fitted ellipse. Correlation analysis identified key buttock morphological parameters that were strongly correlated, enabling the removal of redundant features and the reduction of the computational burden for subsequent modeling. The high-dimensional morphological parameters were reduced using PCA to area and length factors, thus mitigating multicollinearity-driven overfitting while simplifying input dimensionality. When creating estimation models, both GBDT and XGBoost performed well on the test set but showed severe overfitting on the validation set. This may reflect that the true determinants of BFT were largely captured linearly by PCA, with nonlinear relationships not being prominent, which could contribute to overfitting in the ensemble models. EN regression demonstrated superior accuracy and generalization, which likely stems from the model’s integration of L1 regularization (for feature selection) and L2 regularization (for weight constraints), enabling more robust learning of informative patterns. These characteristics enable the model to generalize effectively, making the model particularly suitable when the characteristics of breeding scenarios are considered, where individuals vary markedly and trait ranges fluctuate widely.
Potential sources of error in estimating external morphometric parameters of sows during the experiment include:
  • During feeding, sows often display high-frequency tail sweeping driven by excitement, which produces blurred trails in the images. These blurred regions can generate spurious edge pixels during contour extraction, inflating area measurements and resulting in BFT overestimation. Subsequent studies may include the detection of tail movement amplitude through interframe differences and the use of interpolation between adjacent frames for replacement, thereby reducing errors during the extraction of external morphological parameters.
  • The study focused on the collection of growth data from Jinfen White sows at the gilt and parous stages. Body conformation and fat distribution vary across physiological stages. Changes in abdominal morphology can cause pixel bridging between the abdominal and hip regions in images, which can complicate accurate hip contour segmentation and the extraction of morphological parameters. Subsequent studies should include the collection and categorization of samples from different physiological stages to create a more comprehensive multimodal model for physiological stage identification and prediction, thereby further enhancing the model’s accuracy and adaptability.
In this study, experiments on 254 Jinfen White sows were conducted, and a strong correlation between hip morphological parameters and BFT was confirmed. These results are consistent with the findings of Zhang et al. [12]. The present study used a similar methodological rationale to that of Teng et al., who employed three high-precision depth cameras to capture multiple features, such as rump–thigh area and curvature and establish a BFT prediction model for pigs. The present study aimed to explore a non-contact BFT detection method for pig barn inspection robots, hence utilizing only a single depth camera, resulting in lower accuracy compared to the study of Teng et al. [11]. The experiment has certain limitations. First, the sample included only a single sow breed and confined pen conditions, limiting generalizability to other farming environments such as free-range housing. In addition, the model required fixed image acquisition angles and specific sow postures, which hinders estimates under nonstandard postures and limits full automation. In addition, the model’s MAE was 1.6456 mm. Within practical farming environments, this margin of error may impact the regulation of feed intake and the use of BFT as an auxiliary indicator for nutritional assessment and disease screening. Therefore, future research should expand the range of sample breeds and scenarios, as well as incorporate posture assessment and data augmentation algorithms to enhance the model’s adaptability and robustness in complex real-world settings.
Finally, in this study, an automated BFT estimation system for Jinfen White pigs was developed using PyQt5, enabling the automation of real-time estimation across the entire workflow: image acquisition, ROI identification, parameter extraction, and thickness estimation. The approach integrates animal phenotyping with machine vision, establishing a new paradigm for non-contact measurement. Compared with traditional contact ultrasonic methods, the system enables rapid batch measurements of sows, significantly reducing labor and minimizing sow stress. The system also supports precision feeding through the tracking of BFT changes via periodic image acquisition.

5. Conclusions

In this study, the localization of the ROI region on the buttocks of sows and the relationship between BFT and external morphological characteristics were investigated using DL and image processing techniques. The modified YOLOv8n-ShuffleNetV2 architecture employed demonstrated superior performance in recognition accuracy, achieving a high mAP50-95 value of 94.2%, and resulted in a lightweight design. With relatively small parameter counts and model size (2.79 MB and 5.6 MB, respectively), it exhibited high accuracy in identifying the buttocks ROI area while maintaining lower model complexity. BFT in sows exhibits strong correlations with external morphological features, particularly with the pixel area of the hip and of the fitted ellipse, where Pearson correlation coefficients exceed 90%. Based on the selected hip feature parameters, area and length factors were extracted as input variables for the ML model using PCA. An EN regression model was established for BFT estimation, achieving a coefficient of determination (R2) of 0.8617, with MSE and MAE of 4.3626 mm2 and 1.6456 mm, respectively. Finally, a BFT estimation system for Jinfen White pigs was developed with PyQt5 and Python to automatically preprocess captured sow hip images and estimate BFT in real time. These results demonstrate that DL and image processing can be used to estimate sow BFT, while the technology can be integrated into inspection robots deployed on pig farms for non-contact and efficient estimation. It enables real-time data collection while reducing animal stress and human interference, and it improves measurement efficiency and accuracy, thereby providing reliable support for precision livestock management.

Author Contributions

Data curation, H.L. and X.F.; investigation, Z.L. and P.Y.; methodology, W.X. and J.Z.; project administration, J.Z.; software, W.X. and H.L.; supervision, J.Z.; writing—original draft, W.X.; writing—review and editing, J.Z. and W.X. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by the Shanxi Provincial Basic Research Program (Project No.: 202303021212085), the Chongqing Municipal Special Fiscal Funds Project (Project No.: 24509C), the Zhejiang Provincial Key Laboratory Open Program (Project No.: 2023ZJZD2304), and the key R&D program of Shanxi Province [grant number: 202302010101002].

Institutional Review Board Statement

Only hip depth images and backfat thickness data were collected for the study. The depth image was acquired using a non-contact image acquisition method that did not cause any stress to sows. The process of collecting backfat thickness data is a routine sow management procedure and does not cause additional stress to the sow. Therefore, this study was in compliance with European Union legislation concerning the protection of animals for scientific purposes (European Parliament, 2010). This study was approved by the Experimental Animal Ethics Committee of Shanxi Agricultural University (Approval No. 20230153).

Data Availability Statement

Data will be made available upon reasonable request.

Conflicts of Interest

The authors declare no conflicts of interest.

References

  1. Thitachot, K.; Sirinopwong, V.; Seemuang, V.; Ratchatasriprasert, A.; Kirkwood, R.N.; Am-In, N. Influence of backfat thickness and the interval from altrenogest withdrawal to estrus on reproductive performance of gilts. Animals 2021, 11, 1348. [Google Scholar] [CrossRef]
  2. Ding, R.; Zhuang, Z.; Qiu, Y.; Ruan, D.; Wu, J.; Ye, J.; Cao, L.; Zhou, S.; Zheng, E.; Huang, W. Identify known and novel candidate genes associated with backfat thickness in Duroc pigs by large-scale genome-wide association analysis. J. Anim. Sci. 2022, 100, skac012. [Google Scholar] [CrossRef]
  3. Kim, K.; Hosseindoust, A.; Ingale, S.; Lee, S.; Noh, H.; Choi, Y.; Jeon, S.; Kim, Y.; Chae, B. Effects of gestational housing on reproductive performance and behavior of sows with different backfat thickness. Asian-Australas. J. Anim. Sci. 2015, 29, 142. [Google Scholar] [CrossRef]
  4. Ma, W.; Qi, X.; Sun, Y.; Gao, R.; Ding, L.; Wang, R.; Peng, C.; Zhang, J.; Wu, J.; Xu, Z. Computer vision-based measurement techniques for livestock body dimension and weight: A review. Agriculture 2024, 14, 306. [Google Scholar] [CrossRef]
  5. Fisher, A.V. A review of the technique of estimating the composition of livestock using the velocity of ultrasound. Comput. Electron. Agric. 1997, 17, 217–231. [Google Scholar] [CrossRef]
  6. Ginat, D.T.; Gupta, R. Advances in computed tomography imaging technology. Annu. Rev. Biomed. Eng. 2014, 16, 431–453. [Google Scholar] [CrossRef]
  7. Sharma, S.; Mittal, R.; Goyal, N. An assessment of machine learning and deep learning techniques with applications. ECS Trans. 2022, 107, 8979. [Google Scholar] [CrossRef]
  8. Moutik, O.; Sekkat, H.; Tigani, S.; Chehri, A.; Saadane, R.; Tchakoucht, T.A.; Paul, A. Convolutional neural networks or vision transformers: Who will win the race for action recognitions in visual data? Sensors 2023, 23, 734. [Google Scholar] [CrossRef]
  9. Yu, M.; Zheng, H.; Xu, D.; Shuai, Y.; Tian, S.; Cao, T.; Zhou, M.; Zhu, Y.; Zhao, S.; Li, X. Non-contact detection method of pregnant sows backfat thickness based on two-dimensional images. Anim. Genet. 2022, 53, 769–781. [Google Scholar] [CrossRef]
  10. Li, X.; Yu, M.; Xu, D.; Zhao, S.; Tan, H.; Liu, X. Non-contact measurement of pregnant sows’ backfat thickness based on a hybrid CNN-ViT model. Agriculture 2023, 13, 1395. [Google Scholar] [CrossRef]
  11. Teng GuangHui, T.G.; Shen ZhiJie, S.Z.; Zhang JianLong, Z.J.; Shi Chen, S.C.; Yu JiongHua, Y.J. Non-contact sow body condition scoring method based on Kinect sensor. Trans. Chin. Soc. Agric. Eng. 2018, 34, 211–217. [Google Scholar]
  12. Jian, Y.; Pu, S.; Zhu, J.; Zhang, J.; Xing, W. Estimation of Sow Backfat Thickness Based on Machine Vision. Animals 2024, 14, 3520. [Google Scholar] [CrossRef]
  13. Fernandes, A.F.; Dórea, J.R.; Valente, B.D.; Fitzgerald, R.; Herring, W.; Rosa, G.J. Comparison of data analytics strategies in computer vision systems to predict pig body composition traits from 3D images. J. Anim. Sci. 2020, 98, skaa250. [Google Scholar] [CrossRef]
  14. Alvarez, J.R.; Arroqui, M.; Mangudo, P.; Toloza, J.; Jatip, D.; Rodriguez, J.M.; Teyseyre, A.; Sanz, C.; Zunino, A.; Machado, C. Body condition estimation on cows from depth images using Convolutional Neural Networks. Comput. Electron. Agric. 2018, 155, 12–22. [Google Scholar] [CrossRef]
  15. Azzaro, G.; Caccamo, M.; Ferguson, J.D.; Battiato, S.; Farinella, G.M.; Guarnera, G.C.; Puglisi, G.; Petriglieri, R.; Licitra, G. Objective estimation of body condition score by modeling cow body shape from digital images. J. Dairy Sci. 2011, 94, 2126–2137. [Google Scholar] [CrossRef]
  16. Vieira, A.; Brandão, S.; Monteiro, A.; Ajuda, I.; Stilwell, G. Development and validation of a visual body condition scoring system for dairy goats with picture-based training. J. Dairy Sci. 2015, 98, 6597–6608. [Google Scholar] [CrossRef]
  17. Greer, E.; Mort, P.; Lowe, T.; Giles, L. Accuracy of ultrasonic backfat testers in predicting carcass P2 fat depth from live pig measurement and the effect on accuracy of mislocating the P2 site on the live pig. Aust. J. Exp. Agric. 1987, 27, 27–34. [Google Scholar] [CrossRef]
  18. Yang, W.; Wu, J.; Zhang, J.; Gao, K.; Du, R.; Wu, Z.; Firkat, E.; Li, D. Deformable convolution and coordinate attention for fast cattle detection. Comput. Electron. Agric. 2023, 211, 108006. [Google Scholar] [CrossRef]
  19. Pan, P.; Guo, W.; Zheng, X.; Hu, L.; Zhou, G.; Zhang, J. Xoo-YOLO: A detection method for wild rice bacterial blight in the field from the perspective of unmanned aerial vehicles. Front. Plant Sci. 2023, 14, 1256545. [Google Scholar] [CrossRef]
  20. Ma, N.; Zhang, X.; Zheng, H.-T.; Sun, J. Shufflenet v2: Practical guidelines for efficient cnn architecture design. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 116–131. [Google Scholar]
  21. Wang, J.; Ma, S.; Wang, Z.; Ma, X.; Yang, C.; Chen, G.; Wang, Y. Improved Lightweight YOLOv8 Model for Rice Disease Detection in Multi-Scale Scenarios. Agronomy 2025, 15, 445. [Google Scholar] [CrossRef]
  22. Li, X.; Wu, J.; Zhao, Z.; Zhuang, Y.; Sun, S.; Xie, H.; Gao, Y.; Xiao, D. An improved method for broiler weight estimation integrating multi-feature with gradient boosting decision tree. Animals 2023, 13, 3721. [Google Scholar] [CrossRef] [PubMed]
  23. Ester, M.; Kriegel, H.; Xu, X. XGBoost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016. [Google Scholar]
  24. Cheng, T.; Li, M.; Quan, L.; Song, Y.; Lou, Z.; Li, H.; Du, X. A multimodal and temporal network-based yield Assessment Method for different heat-tolerant genotypes of wheat. Agronomy 2024, 14, 1694. [Google Scholar] [CrossRef]
  25. Zou, H.; Hastie, T. Regularization and variable selection via the elastic net. J. R. Stat. Soc. Ser. B Stat. Methodol. 2005, 67, 301–320. [Google Scholar] [CrossRef]
  26. Jun, H.; Kangting, L.; Tianqi, H.; Yunge, W.; Gang, X. Remote sensing inversion of mangrove biomass based on machine learning. For. Grassl. Resour. Res. 2024, 65–72. [Google Scholar] [CrossRef]
  27. Adeleke, A.A.; Okolie, J.A.; Ogbaga, C.C.; Ikubanni, P.P.; Okoye, P.U.; Akande, O. Machine learning model for the evaluation of biomethane potential based on the biochemical composition of biomass. BioEnergy Res. 2024, 17, 731–743. [Google Scholar] [CrossRef]
Figure 1. Flowchart for estimating BFT in sows.
Figure 1. Flowchart for estimating BFT in sows.
Agriculture 16 00138 g001
Figure 2. (a) Image acquisition of sow buttocks; (b) Sow’s buttocks image acquisition system.
Figure 2. (a) Image acquisition of sow buttocks; (b) Sow’s buttocks image acquisition system.
Agriculture 16 00138 g002
Figure 3. Image enhancement. (a) Original image; (b) Brightening; (c) Flip; (d) Mirroring; (e) Noise addition.
Figure 3. Image enhancement. (a) Original image; (b) Brightening; (c) Flip; (d) Mirroring; (e) Noise addition.
Agriculture 16 00138 g003
Figure 4. Depth gradation chart of sow buttocks. The local depth range of the depth image employs linear normalized mapping, with shading using a ‘blue, green, yellow, red’ pseudo-color mapping. The corresponding depth intervals are: 0–200 (blue), 200–400 (light blue), 400–600 (green), 600–800 (yellow), 800–1000 (red).
Figure 4. Depth gradation chart of sow buttocks. The local depth range of the depth image employs linear normalized mapping, with shading using a ‘blue, green, yellow, red’ pseudo-color mapping. The corresponding depth intervals are: 0–200 (blue), 200–400 (light blue), 400–600 (green), 600–800 (yellow), 800–1000 (red).
Agriculture 16 00138 g004
Figure 5. (a) Structure of YOLOv8. The input layer is responsible for inputting the image to be detected into the network, followed by the backbone layer, which extracts features from the image. The neck layer performs pooling and feature fusion on the input feature layers, while the head layer outputs the final results. (b) YOLOv8n-ShuffleNetV2 architecture diagram.
Figure 5. (a) Structure of YOLOv8. The input layer is responsible for inputting the image to be detected into the network, followed by the backbone layer, which extracts features from the image. The neck layer performs pooling and feature fusion on the input feature layers, while the head layer outputs the final results. (b) YOLOv8n-ShuffleNetV2 architecture diagram.
Agriculture 16 00138 g005
Figure 6. ShuffleNetV2 network architecture: (a) basic unit; (b) unit for spatial down sampling.
Figure 6. ShuffleNetV2 network architecture: (a) basic unit; (b) unit for spatial down sampling.
Agriculture 16 00138 g006
Figure 7. ROI image processing workflow.
Figure 7. ROI image processing workflow.
Agriculture 16 00138 g007
Figure 8. Convergence of YOLOv8n-ShuffleNetV2 (a) loss curve (b) performance indicator curve.
Figure 8. Convergence of YOLOv8n-ShuffleNetV2 (a) loss curve (b) performance indicator curve.
Agriculture 16 00138 g008
Figure 9. Heatmap of Pearson correlation coefficients between BFT and external morphological parameters.
Figure 9. Heatmap of Pearson correlation coefficients between BFT and external morphological parameters.
Agriculture 16 00138 g009
Figure 10. Comparison between ML model predictions and Actual BFT. (a) GBDT; (b) XGBoost; (c) RF; (d) EN; (e) SVM.
Figure 10. Comparison between ML model predictions and Actual BFT. (a) GBDT; (b) XGBoost; (c) RF; (d) EN; (e) SVM.
Agriculture 16 00138 g010
Figure 11. Sow BFT estimation system.
Figure 11. Sow BFT estimation system.
Agriculture 16 00138 g011
Table 1. Statistical Characteristics of BFT Samples in training and test sets for (ML) models (mm).
Table 1. Statistical Characteristics of BFT Samples in training and test sets for (ML) models (mm).
DatasetSample SizeMaximumMinimumMeanStandard Deviation
Training set15229617.135.59
Test set5128616.865.69
Table 2. Performance comparison of different models.
Table 2. Performance comparison of different models.
ModelTrainable
Parameters
Model Size (MB)Training Time (h)MAP50-95Inference Latency (ms)
Yolov8n3,005,8436.34.50.9393.3
Yolov8s11,125,97122.56.50.9415.0
Yolov8m25,840,33952.115.80.94212.0
Yolov8l43,630,61187.530.60.93621.1
Yolov8n-ShuffleNetV22,790,2475.65.80.9423.7
Table 3. Principal component load matrix.
Table 3. Principal component load matrix.
IndicatorLoad Factor
F1F2
AB0.3843−0.0142
AFE0.3842−0.0390
AR0.3821−0.0451
HB0.31650.6515
HH0.3325−0.3498
PB0.3711−0.0609
MIE0.29620.4347
MAE0.3398−0.3373
RC0.32140.3781
Table 4. Parameters selected after optimization based on Bayesian algorithms for different models.
Table 4. Parameters selected after optimization based on Bayesian algorithms for different models.
Machine ModelParameters
GBDTLearning_rate = 0.03, max_depth = 5, min_samples_split = 20, n_estimators = 100
XGBoostcolsample_bytree = 0.769, learning_rate = 0.11, max_depth = 3,
n_estimators = 100, reg_alpha = 1.0, reg_lambda = 1.0, subsample = 0.713
RFmax_depth = 7, min_samples_leaf = 4, min_samples_split = 9, n_estimators = 112
ENAlpha = 0.157, l1_ratio = 0.1, Max_iter = 2000
SVMC = 32, degree = 3, gamma = 0.002
Table 5. Estimation results after optimization based on Bayesian algorithms for different models.
Table 5. Estimation results after optimization based on Bayesian algorithms for different models.
Estimation ModelTraining SetTest SetValidation Set
R2MAEMSER2MAEMSER2MAEMSE
GBDT0.92371.25892.37150.80631.98526.14470.83931.80055.0691
XGBoost0.92931.16722.19680.78452.04786.83400.81871.86925.7175
RF0.88101.50783.69760.78762.02746.73490.81321.88295.8938
EN0.82271.87765.51230.83561.81025.21260.86171.64564.3626
SVM0.81711.88145.68420.82081.84385.68200.85401.67834.6040
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Xing, W.; Li, H.; Fu, X.; Li, Z.; Yi, P.; Zhang, J. Research on Estimating Backfat Thickness in Jinfen White Pigs Using Deep Learning and Image Processing. Agriculture 2026, 16, 138. https://doi.org/10.3390/agriculture16020138

AMA Style

Xing W, Li H, Fu X, Li Z, Yi P, Zhang J. Research on Estimating Backfat Thickness in Jinfen White Pigs Using Deep Learning and Image Processing. Agriculture. 2026; 16(2):138. https://doi.org/10.3390/agriculture16020138

Chicago/Turabian Style

Xing, Wenwen, Hong Li, Xuyang Fu, Ziyu Li, Pengzhe Yi, and Jianlong Zhang. 2026. "Research on Estimating Backfat Thickness in Jinfen White Pigs Using Deep Learning and Image Processing" Agriculture 16, no. 2: 138. https://doi.org/10.3390/agriculture16020138

APA Style

Xing, W., Li, H., Fu, X., Li, Z., Yi, P., & Zhang, J. (2026). Research on Estimating Backfat Thickness in Jinfen White Pigs Using Deep Learning and Image Processing. Agriculture, 16(2), 138. https://doi.org/10.3390/agriculture16020138

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop