A Complete Pipeline to Extract Temperature from Thermal Images of Pigs
Abstract
:1. Introduction
- This study offers a complete pipeline able to automatically detect and track a Region of Interest (ROI) in the thermal videos of pigs moving freely. The pipeline can continuously extract temperature over a long period without any human intervention and save the observed temperature in external files for further analysis. To the best of the authors’ knowledge, this is the first complete pipeline for the automatic extraction of thermal temperature in animals.
- The proposed system can be transferred to be applied on any animal or extended to extract the temperature of other body parts. In addition, thermal imaging is a suitable approach to identify animals, especially in low-light conditions, which is likely the case on most farms, whereas AI has the capabilities of processing and extracting valuable information from recorded data.
- The system can be used to observe the change in the temperature of farm animals over a long period of time, which is crucial for animal research.
2. Related Work
3. Model Architecture
3.1. Stage 1: Classification Model
3.2. Stage 2: Segmentation Model
3.3. Stage 3: Temperature Extraction
4. Dataset
5. Model Implementation
5.1. Classification Model
5.2. Segmentation Model
5.3. Temperature Extraction
6. Results
7. Discussion and Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Boileau, A.; Farish, M.; Turner, S.P.; Camerlink, I. Infrared Thermography of Agonistic Behaviour in Pigs. Physiol. Behav. 2019, 210, 112637. [Google Scholar] [CrossRef] [PubMed]
- Cilulko, J.; Janiszewski, P.; Bogdaszewski, M.; Szczygielska, E. Infrared Thermal Imaging in Studies of Wild Animals. Eur. J. Wildl Res. 2013, 59, 17–23. [Google Scholar] [CrossRef]
- Cruz, S.; Paulino, A.; Duraes, J.; Mendes, M. Real-Time Quality Control of Heat Sealed Bottles Using Thermal Images and Artificial Neural Network. J. Imaging 2021, 7, 24. [Google Scholar] [CrossRef] [PubMed]
- Okada, T.; Fukuhara, T.; Tanaka, S.; Taguchi, M.; Arai, T.; Senshu, H.; Sakatani, N.; Shimaki, Y.; Demura, H.; Ogawa, Y.; et al. Highly Porous Nature of a Primitive Asteroid Revealed by Thermal Imaging. Nature 2020, 579, 518–522. [Google Scholar] [CrossRef] [PubMed]
- Akula, A.; Ghosh, R.; Sardana, H.K.; Predeep, P.; Thakur, M.; Varma, M.K.R. Thermal Imaging And Its Application In Defence Systems. In Proceedings of the OPTICS 2011: International Conference on Light, Kerala, India, 23–25 May 2011; pp. 333–335. [Google Scholar]
- Glehr, M.; Stibor, A.; Sadoghi, P.; Schuster, C.; Quehenberger, F.; Gruber, G.; Leithner, A.; Windhager, R. Thermal Imaging as a Noninvasive Diagnostic Tool for Anterior Knee Pain Following Implantation of Artificial Knee Joints. Int. J. Thermodyn. 2011, 14, 71–78. [Google Scholar] [CrossRef]
- Mayr, H. Thermographic Evaluation After Knee Surgery the Thermal Image in Medicine and Biology; Ammer, K., Ring, E.F., Eds.; Uhlen: Wien, Austria, 1995. [Google Scholar]
- Romanò, C.L.; Romanò, D.; Dell’Oro, F.; Logoluso, N.; Drago, L. Healing of Surgical Site after Total Hip and Knee Replacements Show Similar Telethermographic Patterns. J. Orthopaed. Traumatol. 2011, 12, 81–86. [Google Scholar] [CrossRef]
- Lavers, C.; Franks, K.; Floyd, M.; Plowman, A. Application of Remote Thermal Imaging and Night Vision Technology to Improve Endangered Wildlife Resource Management with Minimal Animal Distress and Hazard to Humans. J. Phys. Conf. Ser. 2005, 15, 207–212. [Google Scholar] [CrossRef]
- Soerensen, D.D.; Pedersen, L.J. Infrared Skin Temperature Measurements for Monitoring Health in Pigs: A Review. Acta Vet. Scand. 2015, 57, 5. [Google Scholar] [CrossRef] [PubMed]
- Lu, M.; He, J.; Chen, C.; Okinda, C.; Shen, M.; Liu, L.; Yao, W.; Norton, T.; Berckmans, D. An Automatic Ear Base Temperature Extraction Method for Top View Piglet Thermal Image. Comput. Electron. Agric. 2018, 155, 339–347. [Google Scholar] [CrossRef]
- Dunbar, M.R.; Johnson, S.R.; Rhyan, J.C.; McCollum, M. Use of Infrared Thermography to Detect Thermographic Changes in Mule Deer (Odocoileus Hemionus) Experimentally Infected with Foot-and-Mouth Disease. J. Zoo Wildl. Med. 2009, 40, 296–301. [Google Scholar] [CrossRef]
- Avni-Magen, N.; Zaken, S.; Kaufman, E.; Kelmer, G. Use of Infrared Thermography in Early Diagnosis of Pathologies in Asian Elephants (Elephas maximus). Isr. J. Vet. Med. 2017, 72, 22–27. [Google Scholar]
- Hilsberg, S. Infrared-Thermography in Zoo Animals: New Experiences with This Method, Its Use in Pregnancy and Inflammation Diagnosis and Survey of Environmental Influences and Thermoregulation in Zoo Animals. In Proceedings of the Second Scientific Meeting, Chester, UK, 21–24 May 1998. [Google Scholar]
- Hilsberg-Merz, S. Infrared Thermography in Zoo and Wild Animals. In Zoo and Wild Animal Medicine; Elsevier: Amsterdam, The Netherlands, 2008; pp. 20–33. ISBN 978-1-4160-4047-7. [Google Scholar]
- Nakayama, K.; Goto, S.; Kuraoka, K.; Nakamura, K. Decrease in Nasal Temperature of Rhesus Monkeys (Macaca mulatta) in Negative Emotional State. Physiol. Behav. 2005, 84, 783–790. [Google Scholar] [CrossRef] [PubMed]
- Sonkusare, S.; Ahmedt-Aristizabal, D.; Aburn, M.J.; Nguyen, V.T.; Pang, T.; Frydman, S.; Denman, S.; Fookes, C.; Breakspear, M.; Guo, C.C. Detecting Changes in Facial Temperature Induced by a Sudden Auditory Stimulus Based on Deep Learning-Assisted Face Tracking. Sci. Rep. 2019, 9, 4729. [Google Scholar] [CrossRef]
- Neethirajan, S. Affective State Recognition in Livestock—Artificial Intelligence Approaches. Animals 2022, 12, 759. [Google Scholar] [CrossRef]
- Cho, Y.; Bianchi-Berthouze, N.; Julier, S.J. DeepBreath: Deep Learning of Breathing Patterns for Automatic Stress Recognition Using Low-Cost Thermal Imaging in Unconstrained Settings. In Proceedings of the 2017 Seventh International Conference on Affective Computing and Intelligent Interaction (ACII), San Antonio, TX, USA, 23–26 October 2017; pp. 456–463. [Google Scholar]
- Kakileti, S.T.; Dalmia, A.; Manjunath, G. Exploring Deep Learning Networks for Tumour Segmentation in Infrared Images. Quant. InfraRed Thermogr. J. 2020, 17, 153–168. [Google Scholar] [CrossRef]
- Mazur-Milecka, M.; Ruminski, J. Deep Learning Based Thermal Image Segmentation for Laboratory Animals Tracking. Quant. InfraRed Thermogr. J. 2021, 18, 159–176. [Google Scholar] [CrossRef]
- Long, J.; Shelhamer, E.; Darrell, T. Fully Convolutional Networks for Semantic Segmentation. In Proceedings of the 2015 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Boston, MA, USA, 7–12 June 2015; pp. 3431–3440. [Google Scholar]
- Zhao, H.; Shi, J.; Qi, X.; Wang, X.; Jia, J. Pyramid Scene Parsing Network. In Proceedings of the 2017 IEEE Conference on Computer Vision and Pattern Recognition (CVPR), Honolulu, HI, USA, 21–26 July 2017; pp. 6230–6239. [Google Scholar]
- Chen, L.-C.; Papandreou, G.; Kokkinos, I.; Murphy, K.; Yuille, A.L. Semantic Image Segmentation with Deep Convolutional Nets and Fully Connected CRFs. arXiv 2014, arXiv:1412.7062. [Google Scholar]
- He, K.; Gkioxari, G.; Dollar, P.; Girshick, R. Mask R-CNN. IEEE Trans. Pattern Anal. Mach. Intell. 2020, 42, 386–397. [Google Scholar] [CrossRef] [PubMed]
- Ronneberger, O.; Fischer, P.; Brox, T. U-Net: Convolutional Networks for Biomedical Image Segmentation. In Medical Image Computing and Computer-Assisted Intervention–MICCAI 2015, Proceedings of the 18th International Conference, Munich, Germany, 5–9 October 2015; Lecture Notes in Computer Science; Navab, N., Hornegger, J., Wells, W.M., Frangi, A.F., Eds.; Springer International Publishing: Cham, Switzerland, 2015; Volume 9351, pp. 234–241. ISBN 978-3-319-24573-7. [Google Scholar]
- Yosinski, J.; Clune, J.; Bengio, Y.; Lipson, H. How Transferable Are Features in Deep Neural Networks? arXiv 2014, arXiv:1411.1792. [Google Scholar] [CrossRef]
- Guo, Y.; Liu, Y.; Georgiou, T.; Lew, M.S. A Review of Semantic Segmentation Using Deep Neural Networks. Int. J. Multimed. Inf. Retr. 2018, 7, 87–93. [Google Scholar] [CrossRef]
- Simonyan, K.; Zisserman, A. Very Deep Convolutional Networks for Large-Scale Image Recognition. arXiv 2014, arXiv:1409.1556. [Google Scholar]
- Amorim Franchi, G.; Moscovice, L.R.; Telkänranta, H.; Pedersen, L.J. Variations in Salivary Oxytocin, Eye Caruncle Temperature and Behavior Indicate Anticipation and Valuing of Environmental Enrichment Material in Fattening Pigs. 2023. Available online: https://papers.ssrn.com/sol3/papers.cfm?abstract_id=4503958 (accessed on 19 January 2025).
- Luo, L.; Zande, L.E.V.D.; Marwijk, M.A.V.; Knol, E.F.; Rodenburg, T.B.; Bolhuis, J.E.; Parois, S.P. Impact of Enrichment and Repeated Mixing on Resilience in Pigs. Front. Vet. Sci. 2022, 9, 829060. [Google Scholar] [CrossRef]
- TELEDYNE FLIR. Print Your Perfect Palette. Available online: https://www.flir.eu/discover/ots/outdoor/your-perfect-palette/?srsltid=AfmBOoqnmKs15fGiPHUfZb1_tDWij6o6RI2uD5w3F_xikHMF1Uye9I44 (accessed on 17 January 2025).
- Taylor, L.; Nitschke, G. Improving Deep Learning with Generic Data Augmentation. In Proceedings of the 2018 IEEE Symposium Series on Computational Intelligence (SSCI), Bangalore, India, 18–21 November 2018; pp. 1542–1547. [Google Scholar]
- Wong, S.C.; Gatt, A.; Stamatescu, V.; McDonnell, M.D. Understanding Data Augmentation for Classification: When to Warp? In Proceedings of the 2016 International Conference on Digital Image Computing: Techniques and Applications (DICTA), Gold Coast, QLD, Australia, 30 November–2 December 2016; pp. 1–6. [Google Scholar]
- Jaccard, P. Distribution de La Flore Alpine Dans Le Bassin Des Dranses et Dans Quelques Regions Voisines. Bull. Soc. Vaudoise Sci. Nat. 1901, 37, 241–272. [Google Scholar]
- Yuan, Y.; Chao, M.; Lo, Y.-C. Automatic Skin Lesion Segmentation Using Deep Fully Convolutional Networks With Jaccard Distance. IEEE Trans. Med. Imaging 2017, 36, 1876–1886. [Google Scholar] [CrossRef] [PubMed]
- Taha, A.A.; Hanbury, A. Metrics for Evaluating 3D Medical Image Segmentation: Analysis, Selection, and Tool. BMC Med. Imaging 2015, 15, 29. [Google Scholar] [CrossRef] [PubMed]
- Ganaie, M.A.; Hu, M.; Malik, A.K.; Tanveer, M.; Suganthan, P.N. Ensemble Deep Learning: A Review. Eng. Appl. Artif. Intell. 2022, 115, 105151. [Google Scholar] [CrossRef]
- Russell, J.A. Core Affect and the Psychological Construction of Emotion. Psychol. Rev. 2003, 110, 145. [Google Scholar] [CrossRef]
- Mendl, M.; Burman, O.H.P.; Paul, E.S. An Integrative and Functional Framework for the Study of Animal Emotion and Mood. Proc. R. Soc. B. 2010, 277, 2895–2904. [Google Scholar] [CrossRef]
- Mendl, M.; Paul, E.S. Animal Affect and Decision-Making. Neurosci. Biobehav. Rev. 2020, 112, 144–163. [Google Scholar] [CrossRef]
- Genno, H.; Ishikawa, K.; Kanbara, O.; Kikumoto, M.; Fujiwara, Y.; Suzuki, R.; Osumi, M. Using Facial Skin Temperature to Objectively Evaluate Sensations. Int. J. Ind. Ergon. 1997, 19, 161–171. [Google Scholar] [CrossRef]
- Kosonogov, V.; De Zorzi, L.; Honoré, J.; Martínez-Velázquez, E.S.; Nandrino, J.-L.; Martinez-Selva, J.M.; Sequeira, H. Facial Thermal Variations: A New Marker of Emotional Arousal. PLoS ONE 2017, 12, e0183592. [Google Scholar] [CrossRef]
- Ramirez Montes De Oca, M.A.; Mendl, M.; Whay, H.R.; Held, S.D.; Lambton, S.L.; Telkänranta, H. An Exploration of Surface Temperature Asymmetries as Potential Markers of Affective States in Calves Experiencing or Observing Disbudding. Anim. Welf. 2024, 33, e45. [Google Scholar] [CrossRef] [PubMed]
- Telkanranta, H.; Paul, E.; Mendl, M. Measuring Animal Emotions with Infrared Thermography: How to Realise the Potential and Avoid the Pitfalls. In Proceedings of the Recent Advances in Animal Welfare Science VI, Newcastle, UK, 28 June 2018. [Google Scholar]
- Kremer, L.; Klein Holkenborg, S.E.J.; Reimert, I.; Bolhuis, J.E.; Webb, L.E. The Nuts and Bolts of Animal Emotion. Neurosci. Biobehav. Rev. 2020, 113, 273–286. [Google Scholar] [CrossRef] [PubMed]
- Leliveld, L.M.C.; Langbein, J.; Puppe, B. The Emergence of Emotional Lateralization: Evidence in Non-Human Vertebrates and Implications for Farm Animals. Appl. Anim. Behav. Sci. 2013, 145, 1–14. [Google Scholar] [CrossRef]
- Gainotti, G. Emotions and the Right Hemisphere: Can New Data Clarify Old Models? Neuroscientist 2019, 25, 258–270. [Google Scholar] [CrossRef] [PubMed]
- Harmon-Jones, E.; Gable, P.A.; Peterson, C.K. The Role of Asymmetric Frontal Cortical Activity in Emotion-Related Phenomena: A Review and Update. Biol. Psychol. 2010, 84, 451–462. [Google Scholar] [CrossRef]
- Goursot, C. Laterality in Pigs and Its Links with Personality, Emotions and Animal Welfare. Ph.D. Thesis, Universität Rostock, Rostock, Germany, 2020. [Google Scholar]
- Badrinarayanan, V.; Kendall, A.; Cipolla, R. SegNet: A Deep Convolutional Encoder-Decoder Architecture for Image Segmentation. IEEE Trans. Pattern Anal. Mach. Intell. 2016, 39, 2481–2495. [Google Scholar] [CrossRef] [PubMed]
- Chen, L.-C.; Zhu, Y.; Papandreou, G.; Schroff, F.; Adam, H. Encoder-Decoder with Atrous Separable Convolution for Semantic Image Segmentation. In Proceedings of the European Conference on Computer Vision (ECCV), Munich, Germany, 8–14 September 2018; pp. 801–818. [Google Scholar]
- Manullang, M.C.T.; Lin, Y.-H.; Lai, S.-J.; Chou, N.-K. Implementation of Thermal Camera for Non-Contact Physiological Measurement: A Systematic Review. Sensors 2021, 21, 7777. [Google Scholar] [CrossRef]
- Jiang, A.; Noguchi, R.; Ahamed, T. Tree Trunk Recognition in Orchard Autonomous Operations under Different Light Conditions Using a Thermal Camera and Faster R-CNN. Sensors 2022, 22, 2065. [Google Scholar] [CrossRef]
- Bashiruddin, J.B.; Mann, J.; Finch, R.; Zhang, Z.; Paton, D. Preliminary Study of the Use of Thermal Imaging to Assess Surface Temperatures during Foot-and-Mouth Disease Virus Infection in Cattle, Sheep and Pigs. In Proceedings of the 2006 Session of the Research Group of the Standing Technical Committee of the European Commission for the Control of Foot-and-Mouth Disease, Paphos, Cyprus, 17–20 October 2006; Food and Agriculture Organization: Rome, Italy, 2006; pp. 304–308. [Google Scholar]
- Rainwater-Lovett, K.; Pacheco, J.M.; Packer, C.; Rodriguez, L.L. Detection of Foot-and-Mouth Disease Virus Infected Cattle Using Infrared Thermography. Vet. J. 2009, 180, 317–324. [Google Scholar] [CrossRef]
- Menegassi, S.R.O.; Pereira, G.R.; Dias, E.A.; Koetz, C.; Lopes, F.G.; Bremm, C.; Pimentel, C.; Lopes, R.B.; Da Rocha, M.K.; Carvalho, H.R.; et al. The Uses of Infrared Thermography to Evaluate the Effects of Climatic Variables in Bull’s Reproduction. Int. J. Biometeorol. 2016, 60, 151–157. [Google Scholar] [CrossRef] [PubMed]
- Rizzo, M.; Arfuso, F.; Alberghina, D.; Giudice, E.; Gianesella, M.; Piccione, G. Monitoring Changes in Body Surface Temperature Associated with Treadmill Exercise in Dogs by Use of Infrared Methodology. J. Therm. Biol. 2017, 69, 64–68. [Google Scholar] [CrossRef] [PubMed]
- Scolari, S.; Evans, R.; Knox, R.; Tamassia, M.; Clark, S. 41 Determination of the Relationship Between Vulvar Skin Temperatures and Time of Ovulation in Swine Using Digital Infrared Thermography. Reprod. Fertil. Dev. 2010, 22, 178. [Google Scholar] [CrossRef]
- Scolari, S.; Clark, S.; Knox, R.; Tamassia, M. Vulvar Skin Temperature Changes Significantly during Estrus in Swine as Determined by Digital Infrared Thermography. JSHAP 2011, 19, 151–155. [Google Scholar] [CrossRef]
- Simões, V.G.; Lyazrhi, F.; Picard-Hagen, N.; Gayrard, V.; Martineau, G.-P.; Waret-Szkuta, A. Variations in the Vulvar Temperature of Sows during Proestrus and Estrus as Determined by Infrared Thermography and Its Relation to Ovulation. Theriogenology 2014, 82, 1080–1085. [Google Scholar] [CrossRef] [PubMed]
- Zheng, S.; Zhou, C.; Jiang, X.; Huang, J.; Xu, D. Progress on Infrared Imaging Technology in Animal Production: A Review. Sensors 2022, 22, 705. [Google Scholar] [CrossRef] [PubMed]
- Redaelli, V.; Zaninelli, M.; Martino, P.; Luzi, F.; Costa, L.N. A Precision Livestock Farming Technique from Breeding to Slaughter: Infrared Thermography in Pig Farming. Appl. Sci. 2024, 14, 5780. [Google Scholar] [CrossRef]
Parameter Name | Selected Value | |
---|---|---|
Model setting | Input size | 320 × 320 × 3 |
Optimizer | SGD | |
Learning rate | 1 × 10−3 | |
Momentum | 0.9 | |
Training setting | Loss function | Binary cross-entropy |
Batch size | 32 | |
Epoch | 300 | |
ReduceLROnPlateau | Monitor | Valid loss |
Patience | 6 | |
Factor | 0.8 | |
Environment | GPU | NVIDIA Quadro RTX 5000 |
Platform | Python 3.9 | |
Tool box | Tensorflow |
Parameter Name | Selected Value | |
---|---|---|
Model setting | Input size | 768 × 1024 × 3 |
Optimizer | SGD | |
Learning rate | 1 × 10−4 | |
Momentum | 0.9 | |
Training setting | Loss function | Jaccard loss |
Batch size | 2 | |
Epoch | 300 | |
ReduceLROnPlateau | Monitor | Valid loss |
Patience | 10 | |
Factor | 0.8 | |
Environment | GPU | NVIDIA Quadro RTX 5000 |
Platform | Python 3.9 | |
Tool box | Tensorflow |
Frame | Left Temp 1 | Right Temp | L_pos 2 | R_pos |
---|---|---|---|---|
0 | 39.83 | 39.48 | (652, 667) | (724, 614) |
1 | 39.78 | 39.45 | (631, 673) | (718, 619) |
2 | 39.56 | 39.38 | (623, 679) | (709, 636) |
3 | 39.53 | 39.24 | (615, 690) | (694, 649) |
4 | 39.55 | 39.20 | (599, 698) | (682, 660) |
5 | 39.39 | 39.20 | (576, 712) | (665, 674) |
Model Architecture | Accuracy | False-Positive Rate |
---|---|---|
ResNet-50 | 97.4% | 1.62% |
VGG-16 | 96.9% | 2.12% |
Inception | 97.7% | 1.52% |
ResNet-101 | 95.8% | 2.88% |
Xception | 96.8% | 2.67% |
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. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Bekhit, R.; Reimert, I. A Complete Pipeline to Extract Temperature from Thermal Images of Pigs. Sensors 2025, 25, 643. https://doi.org/10.3390/s25030643
Bekhit R, Reimert I. A Complete Pipeline to Extract Temperature from Thermal Images of Pigs. Sensors. 2025; 25(3):643. https://doi.org/10.3390/s25030643
Chicago/Turabian StyleBekhit, Rodania, and Inonge Reimert. 2025. "A Complete Pipeline to Extract Temperature from Thermal Images of Pigs" Sensors 25, no. 3: 643. https://doi.org/10.3390/s25030643
APA StyleBekhit, R., & Reimert, I. (2025). A Complete Pipeline to Extract Temperature from Thermal Images of Pigs. Sensors, 25(3), 643. https://doi.org/10.3390/s25030643