journal article·2025-06-18Open access

Image Segmentation and Measurement of Trout Using a Convolutional Neural Network and Transformer Architecture

Jose Cruz, Luis Baca, Raul Castillo, Eudes Apaza, Christian Romero, Ferdinand Pineda

Applied Sciences· Volume 15· Issue 12

Abstract

Aquaculture plays a vital role in meeting global food demands, necessitating technological innovations for sustainable production. This study investigates deep learning-based semantic image segmentation for enhanced monitoring of rainbow trout (Oncorhynchus mykiss) in Puno, Peru. We conducted three experiments using UNET and UNETR architectures, varying image resolution, loss functions, and optimizers on a dataset of 1200 high-resolution images. Experiment 1, with UNET and 256 × 256 pixel images, achieved an IoU of 0.942854 after 20 epochs, using MSELoss and Adam, demonstrating superior segmentation accuracy. Experiment 2, utilizing UNET with 512 × 512 pixel images, resulted in an IoU of 0.803244 after 50 epochs, with L1Loss and Adam, indicating satisfactory performance despite increased complexity. Experiment 3, employing UNETR with 256 × 256 pixel images, yielded lower IoU scores, with a best IoU of 0.253928, highlighting the challenge of training Transformer-based models with limited data. A critical aspect of this study was the use of a coin as a scale reference in all experiments, enabling precise conversion of pixel measurements to physical dimensions. This, combined with OpenCV for contour detection, allowed for accurate fish size estimations, validated by comparisons with real images. The results underscore UNET’s effectiveness for aquaculture image segmentation, while also emphasizing data requirements for UNETR. This approach provides a non-invasive, automated method for monitoring fish growth and health, contributing to sustainable aquaculture practices.
Source: crossref · Quality: baseline

Research context

OpenAlex topics: Water Quality Monitoring Technologies · Fish biology, ecology, and behavior · Fish Ecology and Management Studies

SciVX discovery tags are terminology-based. OpenAlex topics are source-provided classifications.

Affiliations

E.P. Ingenieria Electronica, Universidad Nacional del Altiplano, Puno 21002, Peru

Funding

Universidad Nacional del Altiplano—FEDU

References (31)

Show source-provided references
1. FAO (2022). The State of World Fisheries and Aquaculture 2022: Towards Blue Transformation, FAO.
2. The contribution of aquaculture systems to global aquaculture production10.1111/jwas.12963 ↗
3. Modeling framework for establishing the power law between length and weight of fishes and a meta-analysis for validation of LWRS for six commercially important marine fishes from the northwestern Bay of Bengal10.1016/j.fishres.2022.106496 ↗
4. Evaluating the influence of environmental variables on the length-weight relationship and prediction modelling in flathead grey mullet, Mugil cephalus Linnaeus, 175810.7717/peerj.14884 ↗
5. Weight–length relationship in fish populations reflects environmental regulation on growth10.1007/s10750-022-05072-8 ↗
6. Burger, W., and Burge, M.J. (2022). Digital Image Processing: An Algorithmic Introduction, Springer Nature.10.1007/978-3-031-05744-1 ↗
7. Image segmentation using deep learning: A survey
8. Fernandes, A.F.A., Dórea, J.R.R., and Magalhães Rosa, G.J. (2020). Image analysis and computer vision applications in animal sciences: An overview. Front. Vet. Sci., 7.10.3389/fvets.2020.551269 ↗
9. Deep learning tools for the measurement of animal behavior in neuroscience10.1016/j.conb.2019.10.008 ↗
10. A review on computer vision systems in monitoring of poultry: A welfare perspective
11. Li, G., Huang, Y., Chen, Z., Chesser, G.D., Purswell, J.L., Linhoss, J., and Zhao, Y. (2021). Practices and applications of convolutional neural network-based computer vision systems in animal farming: A review. Sensors, 21.10.3390/s21041492 ↗
12. Validation of a digital video tracking system for recording pig locomotor behaviour10.1016/j.jneumeth.2004.09.019 ↗
13. Arganda-Carreras, I., Turaga, S.C., Berger, D.R., Cireşan, D., Giusti, A., Gambardella, L.M., Schmidhuber, J., Laptev, D., Dwivedi, S., and Buhmann, J.M. (2015). Crowdsourcing the creation of image segmentation algorithms for connectomics. Front. Neuroanat., 9.10.3389/fnana.2015.00142 ↗
14. Saidi, A., Cavallo, C., Puleo, S., Del Giudice, T., and Cicia, G. (2024). Defining traceability attributes and consumers’ segmentation based on fish attributes: A case study in Italy and Spain. Foods, 13.10.3390/foods13162518 ↗
15. Multi-scale fish segmentation refinement and missing shape recovery10.1109/ACCESS.2019.2912612 ↗
16. Deep learning image segmentation for extraction of fish body measurements and prediction of body weight and carcass traits in Nile tilapia10.1016/j.compag.2020.105274 ↗
17. Ronneberger, O., Fischer, P., and Brox, T. (2025, January 10). U-Net: Convolutional Networks for Biomedical Image Segmentation. Available online: https://arxiv.org/abs/1505.04597.
18. Hatamizadeh, A., Yin, Y., Myronenko, A., Xiao, Y., Foote, D., Lam, F., Roth, H., and Xu, Z. (2021). UNETR: Transformers for 3D Medical Image Segmentation. arXiv.10.1109/WACV51458.2022.00181 ↗
19. Dosovitskiy, A., Beyer, L., Kolesnikov, A., Weissenborn, D., Zhai, X., Unterthiner, T., Dehghani, M., Minderer, M., Heigold, G., and Gelly, S. (2020). An Image is Worth 16 × 16 Words: Transformers for Image Recognition at Scale. arXiv.
20. Panboonyuen, T., Pattanakiat, S., Dhital, D., Lawawirojwong, S., Jitkajornwanich, K., and Limprasert, W. (2021). Transformer-Based Decoder Designs for Semantic Segmentation on Remotely Sensed Images. Remote Sens., 13.10.3390/rs13245100 ↗
21. Ghali, R., Hajek, P., Abdelkrim, A., Forestier, G., Fromont, E., Adam, S., and Gancarski, P. (2021). Wildfire Segmentation Using Deep Vision Transformers. Remote Sens., 13.10.3390/rs13173527 ↗
22. Matute, G., Barrón, E., Morón, A., Murillo, J., and Rivera, J.C. (2025, January 10). Truchicultura en la Región Puno. Available online: https://repositorio.esan.edu.pe/items/5d57acf1-11e5-41fc-80bd-9150eae77147.
23. Observations sur les poissons de la partie bolivienne du lac Titicaca: 4: Orestias spp., Salmo gairdneri et problèmes d’aménagement
24. Comparative environmental performance of artisanal and commercial feed use in Peruvian freshwater aquaculture10.1016/j.aquaculture.2014.08.001 ↗
25. First description of Weissella ceti associated with mortalities in farmed rainbow trout (Oncorhynchus mykiss) in Peru10.1016/j.aquaculture.2020.735608 ↗
26. Long, J., Shelhamer, E., and Darrell, T. (2025, January 10). Fully Convolutional Networks for Semantic Segmentation. Available online: https://arxiv.org/abs/1411.4038.
27. Wilson, E., and Flores, M. (2025, January 10). Classification of Fish Freshness Using a Convolutional Neural Network. Available online: https://www.researchsquare.com/article/rs-3547262/v2.
28. Pineda, F., and Cruz, J. (2023, January 10–13). Classification model based on deep learning with hybrid loss function for trout freshness analysis. Proceedings of the 2023 IEEE 7th Ecuador Technical Chapters Meeting (ECTM), Ambato, Ecuador.10.1109/ETCM58927.2023.10309072 ↗
29. Wada, K. (2025, January 10). Labelme: Image Polygonal Annotation with Python. Available online: https://github.com/wkentaro/labelme.
30. Fu, L., and Li, S. (2023). A new semantic segmentation framework based on UNet. Sensors, 23.10.3390/s23198123 ↗
31. Rezatofighi, H., Tsoi, N., Gwak, J., Sadeghian, A., Reid, I., and Savarese, S. (2019, January 15–20). Generalized Intersection Over Union: A Metric and a Loss for Bounding Box Regression. Proceedings of the 2019 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Los Alamitos, CA, USA. Available online: https://doi.ieeecomputersociety.org/10.1109/CVPR.2019.00075.10.1109/CVPR.2019.00075 ↗