- The paper demonstrates a novel noninvasive pig identification system using auricular vein patterns with 98.12% accuracy in mixed-breed populations.
- The system employs adaptive ROI extraction, advanced image processing, and a 68-dimensional feature vector for robust classification.
- The approach enables low-cost, real-time deployment on smartphones, offering a scalable solution for small-scale farming.
Cross-Breed Pig Identification via Auricular Vein Pattern Recognition: A Machine Learning Pipeline for Small-Scale Farming
Introduction
This work addresses the persistent challenge of reliable, cost-effective pig identification in small-scale farming, where traditional methods such as RFID tags, ear notching, and microchips are often impractical due to cost, maintenance, and technical barriers. The authors propose a noninvasive biometric system leveraging the uniqueness and stability of auricular vein patterns, captured using commodity smartphone cameras and simple backlighting. The system is designed to be robust across mixed-breed populations, a scenario largely unaddressed in prior research, and is optimized for computational efficiency to enable real-time deployment in resource-constrained environments.
System Architecture and Pipeline
The proposed identification system is structured as a multistage computer vision and machine learning pipeline, beginning with raw image acquisition and culminating in individual pig identification.
Figure 1: Complete pipeline architecture for pig identification using auricular vein patterns, illustrating the sequential processing stages from raw ear image acquisition through ROI extraction, vein feature extraction, feature vector generation, to final machine learning classification for individual pig identification.
Data Acquisition
A dataset of 800 ear images from 20 mixed-breed pigs (Landrace × Pietrain and Duroc × Pietrain) was collected using a 12 MP smartphone camera under controlled lighting. The imaging protocol involved backlighting the ear to enhance vein visibility, with each pig contributing 40 images. Stratified sampling ensured balanced train-test splits.
The ROI extraction isolates the inner ear region, maximizing the signal-to-noise ratio for vein analysis. The process exploits the dominance of the red channel under backlighting, employing a custom adaptive thresholding pipeline that dynamically adjusts thresholds based on image statistics (mean, standard deviation, and channel ratios). Morphological operations (closing, opening) and connected component analysis are used to refine the mask, ensuring robust segmentation across variable lighting and pigmentation.
Figure 2: ROI extraction process showing: (a) original ear image, (b) refined mask after morphological operations, and (c) final masked inner ear region for vein analysis.
Vein extraction proceeds via red channel inversion, CLAHE-based contrast enhancement, and image sharpening. Adaptive thresholding binarizes the image, followed by morphological cleaning to remove noise and connect fragmented veins. The Canny edge detector is applied for precise edge localization, and skeletonization reduces vein structures to one-pixel-wide representations. Feature extraction focuses on endpoints, bifurcations, and uniformly sampled skeleton points, capturing both local and global vein topology.
Figure 3: Vein extraction pipeline showing: (left) original ear image, (center) masked inner ear region, and (right) extracted vein patterns after processing.
Feature Vector Construction
A 68-dimensional feature vector is constructed, comprising:
- Counts of bifurcation and endpoint features
- Statistical descriptors (mean, std) of interpoint distances
- Spatial distribution statistics (mean, std of x and y coordinates)
- Angular histograms of bifurcation orientations (8 bins)
- Spatial density histograms of sampled skeleton points (50 bins)
This representation encodes structural, spatial, and geometric properties of the vein network, providing a discriminative basis for classification.
Classification
Four classifiers were evaluated: SVM (RBF kernel), Random Forest, KNN, and Logistic Regression. SVM consistently outperformed alternatives, achieving 98.12% accuracy on mixed-breed populations, with minimal variance across experimental configurations. The pipeline is computationally efficient, with an average end-to-end processing time of 8.3 seconds per image on standard smartphone hardware.
Experimental Results
The custom adaptive thresholding and morphological refinement pipeline demonstrated robust ROI segmentation across diverse lighting and pigmentation conditions. The vein extraction process reliably isolated complex vascular networks, yielding high-quality features for downstream analysis.
SVM achieved 98.12% accuracy on the mixed-breed dataset, with only 1.88% error rate (3 false positives and 3 false negatives out of 160 test images). Errors were randomly distributed, with no breed-specific bias, indicating that the feature representation generalizes well across breeds.
Figure 4: SVM confusion matrix for mixed-breed classification showing high diagonal accuracy with minimal off-diagonal misclassifications.
Random Forest and KNN also demonstrated stable performance (95–97.5%), but SVM's ability to model nonlinear decision boundaries in the high-dimensional feature space yielded superior generalization. Logistic Regression exhibited overfitting on small subsets and underperformed on larger, more variable datasets.
Comparison with Prior Work
Compared to prior auricular vein-based pig identification systems, which were limited to single-breed, controlled settings and relied on less comprehensive feature sets (e.g., HOG descriptors, branching point templates), the proposed method demonstrates competitive accuracy (98.12%) in a more challenging mixed-breed scenario. The 68-dimensional feature vector integrates multiple complementary aspects of vein morphology, enhancing robustness to breed variability and environmental noise.
Practical and Theoretical Implications
The system's reliance on low-cost imaging hardware and computationally lightweight algorithms makes it suitable for deployment in small-scale, resource-constrained farming environments. By eliminating the need for physical identifiers, the approach reduces animal stress, maintenance costs, and the risk of identifier loss or tampering. The demonstrated cross-breed robustness addresses a critical gap in the literature, supporting broader adoption in heterogeneous farm populations.
Theoretically, the work validates the discriminative power of auricular vein patterns as a biometric modality for livestock, extending the applicability of vein-based biometrics beyond controlled, single-breed contexts. The feature engineering approach—integrating structural, spatial, and geometric descriptors—provides a template for future biometric systems in other species or modalities.
Limitations and Future Directions
Despite strong performance, the system exhibits a small but non-negligible error rate, primarily due to natural individual variation in vein patterns. Future work should address:
- Temporal stability analysis to assess the persistence of vein patterns over time and under physiological changes
- Multimodal fusion with other biometric traits (e.g., facial features) to further reduce error rates and provide redundancy
- Scaling to larger, more diverse populations and additional breeds to validate generalization
- Integration with farm management systems for automated health monitoring, traceability, and productivity analytics
Conclusion
This study presents a practical, accurate, and efficient cross-breed pig identification system based on auricular vein pattern recognition, optimized for small-scale farming applications. The multistage pipeline—from adaptive ROI extraction to high-dimensional vein feature engineering and SVM classification—demonstrates robust performance in mixed-breed populations using only commodity hardware. The approach addresses key limitations of prior work and offers a scalable pathway toward digitized, precision livestock management in resource-constrained settings.