COMPUTER VISION FOR MORPHOMETRIC EVALUATION OF BROILER CHICKEN BONES

Locomotor problems are a challenge for commercial poultry, but current methods used to assess the bone structure of chickens are few and laborious. The objective of this study is to present software for the automatic extraction of morphometric characteristics of broiler chicken’s locomotor bones throughout the life cycle, by applying computer vision techniques. 112 samples from the tibia and 112 from the femur of commercial chickens were used, subdivided by age (0, 7, 14, 21, 28, 35, and 42 days). The images were digitally processed to extract bone morphometric properties (area, length, and perimeter). New software was created, including the proposed processing and algorithms for obtaining the morphometric characteristics. Classification models (artificial neural networks, and k-nearest neighbors’ algorithm, were developed to classify bones and type. The results of the were opens new possibilities for evaluative of


INTRODUCTION
Locomotor problems in chickens are one of the main bottlenecks in today's broiler poultry industry, as the industry is based on the rapid growth of animals and, consequently, the difficulties that broiler chickens have in sustaining their own weight (Rath et al., 2000;Colet et al., 2015;Fernandes, 2016). Poor bone conformation of broilers, which becomes more visible in the last weeks of life, is a reflection of the rapid great muscular development of the animals due to genetic modifications and feeding management. At the same time, the skeletal support system is still immature, even in the slaughter phase. (Mabelebele et al., 2017). As a consequence, injuries and deformities in the legs are recurrent, which in turn leads to decreased bone strength and a higher incidence of fractures (Garcia et al., 2018).
Under economic bias, measurable losses occur due to the condemnation and declassification of carcasses due to leg injuries. In contrast, non-measurable losses occur due to reductions in the animals' productive performance, such as a decreased weight gain and increased feed conversion (Alves et al., 2016). In this scenario, Paz (2008) andMendonça Junior (2000) highlighted that the disposal of birds in a slaughter line and the occurrence of chicks as a result of bone problems represent up to between 3 to 7% of the Brazilian chicken production, generating quite significant losses.
Furthermore, locomotor problems of birds have been widely discussed from the perspective of animal welfare (Nääs et al., 2010;Buijs et al., 2012;Garcia et al., 2018). Studies indicate that the natural behavior of chickens can be altered by irregular bone development, with leg weakness being a source of pain and an impediment to walking. Paz (2008) also highlighted these issues, when considering the five freedoms of animal welfare according to the principles of the FAWC (Farm Animal Welfare Council).
Several studies have been carried out with an interest in evaluating the quality of locomotor bones of broiler chickens -through their chemical, morphometric and biomechanical properties -with an emphasis on the bones of the tibia and the femur. Regarding the morphometric (or geometric) characteristics of the bones, we want to highlight the evaluation of weight (with precision scales), maximum length (determined manually with the aid of a caliper), cross-sectional area (commonly determined with a measurement of the internal bone diameter) (Barbosa et al., 2010;Reis et al., 2011;Han et al., 2015;Mabelebele et al., 2017) and more specific measurements, such as the proximal width, distal condyle width and distal condyle depth (Yalcin et al., 2001). These characteristics aim to complement studies on bone biomechanics, in which the maximum shape, flexural strength, moment of inertia, and the elasticity module of the bones are measured.
However, although some methodologies for assessing the properties of the locomotor system of broilers have already been consolidated in the literature (Adhikari et al., 2019;Gebhardt-Henrich et al., 2017;Turner & Burr, 1993;Rath et al., 2000), there is great potential for incorporating little or not yet explored characteristics, such as area, perimeter, and others, to describe the bone development of birds. Currently, this is limited by a lack of specific equipment and/or methods that require a large amount of time and work.
Although there are no studies which apply digital image processing and computer vision to broiler chicken bones, it is possible to find techniques in the literature which are usually used to evaluate structures of human skeletons, mainly to diagnose diseases (Rastegar et al., 2020;Yu et al., 2016;Korfiatis et al., 2017) and assess bone strength (Tanaka et al., 2001). From the poultry side, systems based on computer vision has been used to measure and evaluate other characteristics, as chicken weight, carcass evaluation and egg characteristics -such as volume, size grading and surface area (Nyalala et al., 2021). Koodtalang & Sangsuwan (2019) developed a technique to classify the size of chicken legs in three groups (small, medium and large) using deep neural network as a machine learning model.
Thus, engineering techniques based on artificial intelligence, image processing, data analysis, and computer vision are welcomed for finding low-cost and practical alternatives in examining chickens' bone characteristics. With that in mind, the objective of this work is to develop and validate a software for the extraction of biometric characteristics of locomotor bones of broilers, followed by the classification of the bones by type -femur or tibia -and age of the chickens, using computer vision techniques. The primary purpose was to provide a rapid and broader evaluation of broiler locomotive systems, as a potential tool for diagnosing bone problems in birds.

Sample collection and preparation
A total of 56 broiler birds of the Cobb strain were used for this study, both sexes, housed in a climatic chamber. Animal experimental procedures were approved by the Ethics Commission for Animal Use, protocol number 2016/10, of CEUA/ESALQ/USP, Piracicaba, São Paulo, Brazil. The birds had access ad libitum to water, feed, and unrestricted use of beds made of rice straw. The temperature and relative humidity of the environment were controlled inside the chamber and conditions of thermal comfort were maintained throughout the study, according to the requirements of the breed. The housing density was 12 m²/bird -when taking into account the feeding and drinking areas -thus, respecting the ideal space recommended for housing birds (Azzam & El-Gogary, 2015). Eight birds from the flock were randomly collected in weekly intervals, at the ages of 0 (first day of life), 7, 14, 21, 28, 35, and 42 days. The animals were euthanized, and the right and left legs were removed, followed by identification, packaging in plastic bags, and storage at -20 ºC, according to the procedure performed by Reis et al. (2011) and Barbosa et al. (2010). After that, the legs were stripped, and the tibia and femur were extracted from the birds' locomotor ensemble, thereby obtaining 4 samples per bird: right tibia, left tibia, right femur and left femur. A sample bank of 224 bones was generated, cataloged according to the type of bone (112 tibias, T, and 112 femurs, F) and age of the broiler chickens (32 bones per age). In the end, 14 classes of bones were generated ( Fig. 1): T0, T7, T14, T21, T28, T35, T42, F0, F7, F14, F21, F28, F35, and F42. FIGURE 1. General scheme of the image acquisition system, the sample bank and the stages of digital processing and classification by the computer vision model.

Image acquisition
For capturing the images, a computer vision system containing three central elements was proposed, as exemplified by Pereira et al. (2018) and Nyalala et al. (2021): a lighting source, a smooth bottom surface, and a digital camera (Fig. 1). The images were taken in an experimental laboratory without windows, with a constant artificial light source (fluorescent lights) without any interference from external lighting. The background was a smooth surface covered with ethylene-vinyl acetate, in a matte black color, which was found to generate the best contrast with the color of the bones and to minimize possible shading effects. A 20.1-megapixel Cyber-shot DSCH300B (Sony, Japan) digital camera was positioned at a 90° angle to the bottom, supported on a tripod of a height of 25 cm. The standard digital camera settings for the entire sample bank were maintained. Each sample (bone) was thawed, cleaned, and dried immediately before the images were captured. The images were saved in .jpeg format and downloaded via USB to a computer for digital processing.

Image processing and feature extraction
Digital processing of the images was performed in MATLAB®, version R2015a (Mathworks, USA). During pre-processing, a segmentation of the bones, and the extraction of morphometric parameters from the detected objects were performed. As the main interest of the research was the geometric characterization of the bones, and not their coloring, the images were initially converted from RGB to grayscale "g (x, y)" and later thresholded "f (x, y)," according to [eq. (1)]. After empirical tests, a global threshold of 0.16 was determined to be the one that best fit the processing developed in this study.
The proposed code also included two algorithms for cleaning noise, in order to eliminate possible problems with object identification (pixels representative of the background recognized as bone or pixels representative of the bone recognized as background). The first of these consisted of the filling of regions, whereas the edges of the objectives were initially recognized in the image and later filled with functions available in MATLAB® itself. The second cleaning algorithm was developed according to a set theory exemplified by Gonzalez & Woods (2000) and Dougherty (2018), through basic morphological operations of erosion followed by dilation of the same intensity. A 3x3 square was used as a structuring element -which presented better results when compared with other structuring elements previously evaluated.
After processing, which resulted in the integral segmentation of the object of interest, functions for the extraction of morphometric parameters were included: the area of the bones (A), the length (l) and the perimeter (p). For the calculation of the area and perimeter, it was considered the estimative given in pixels of the connect components in the image -which characterize the bones. The length was obtained by calculating the Euclidean distance for each point in the bone region to the most distant non-zero pixel. After that, the longest Euclidean distance found was returned, thereby obtaining the maximum possible length of the bone. It is worth noting that the values of A, c, and p were obtained according to pixels, thereby later requiring conversion to real values (cm² and cm). For this, we used a standard object (a white square) of previously known geometric properties (A = 100 cm², l = 14.15 cm and p = 40 cm), whose image was captured and processed using the same procedure described previously, thereby allowing for the conversion of the pixel values of the bones to real values. The mean and standard deviation from the morphometric parameters for each type of bone and broiler chicken age (both in pixels and real values) was considered in this study.

Software development
The digital processing developed in this project was included in the software in order to be able to use it as a potential tool for future studies in bone morphometry of broiler chickens. The software was also developed in the MATLAB platform using GUIDE (Graphical User Interface Development Environment) environment, which offers a set of tools (buttons, menus, visualization screens, and other graphic elements) that allow for the elaboration of event-oriented programming. Each event is associated with a "callback" function, which has to be triggered by the user (Sari et al., 2021).
During the development of the software interface (Fig. 2), the use of three graphic screens was proposed, allowing the user to view the original image (color), the binarized image, and the segmented image (only the bone, after the entire filtering process). In the segmented image, commands were used to highlight the edges of the bones (black outline), to highlight the object (colored) in contrast to the background (gray), and add bone area, in pixels, to the image itself. Control buttons were used to open the original image, save the segmented image (for future use and registration) and reset the software, clearing all images and text fields. The processing was subdivided into two methods. First, the direct method, through the button "binarize: direct method," which uses the fixed threshold of 0.16. The second method is the indirect method, through the "binarize: indirect method" button, which allows the user to choose -through a slide -a threshold from 0, completely black, to 1, completely white. Greater emphasis was given to the button "get biometric variables," which is the main objective of the software, and is in the box of biometric variables, which returns the values of A, l, and p in pixels and their corresponding real values. The versatility of the software was evaluated using examples of images of the femur and tibia bones of broilers, taken from broiler chickens of different ages. The test images came from different capture systems, different backgrounds (white and black), lighting (controlled and uncontrolled), and photographic devices (semi-professional and cellular camera).

Classification and validation
An artificial intelligence approach was proposed for the identification, training, and classification of apparent patterns in the generated morphometric database. Data analysis was performed in MATLAB®, version R2015a (Mathworks, USA). For this, the 14 classes of bone structures initially extracted were used, sorted according to the age of the animals (0, 7, 14, 21, 28, 35 and 42) and the type of bone (femur or tibia). No distinctions were made between bones extracted from the left or right legs or different sexes (male or female).
The morphometric measurements obtained according to the description in Section 2.3 were used as input data: area, length, and perimeter of bones. Two methods were used for the classification: a neural network backpropagation (BPNN) and the k-nearest neighbor (KNN), which are models widely used in the animal production chain (Grilli et al., 2018;Nyalala et al., 2021). BPNN is a tool belonging to a set of artificial neural networks (ANN), initially developed by Rumelhart et al. (1985). This model acts as a minimizer of the error that is observed in the output of the network, making adjustments in the layers of the neural network. The BPNN used in this work consisted of three layers, with three neurons in the input layer (morphometric parameters) and one neuron in the output layer (with output signals from 1 to 14, associated with the 14 available classes). The database was used in empirical tests to determine the number of neurons used in the hidden layer. The Levenberg-Marquardt algorithm was used as a training model for the input data. A logarithmic sigmoid function was used as an activation function.
The KNN, in turn, is a non-parametric classification method, known for its simplicity and adaptability to various situations. The metric used for the classification by the nearest neighbor k was the Euclidean distance, which is one of the most common models for determining the distance between two points X = (x1, x2, ..., xn) and Y = (y1, y2, ..., yn). Guo et al. (2003) highlighted that the success of KNN is dependent on the value of k (closest neighbors), whereby the classic method of choosing the correct value is to experiment with different values of k using the same algorithm and data set. The k with the best result is chosen empirically.
As a type of sampling technique for manipulating training sets and testing the artificial neural network, 50% of the data was used to train the network effectively, 25% for validation, and 25% for tests. For KNN, 75% of the data was used for training, and 25% selected for testing. The accuracy was the evaluation metric used to compare the models, which is also applied in other studies (Koodtalang & Sangsuwan, 2019;Swanson & Gowen, 2021).

Results of image processing
Starting from a colored image, the digital processing of the images comprised the stages of binarization and noise cleaning (Fig. 3). It is essential to highlight the importance of the thresholding process, as it is a crucial step for the success of the following steps in the digital processing of bone images. Tanaka et al. (2001) and Jun et al. (2018), when working with human bones, highlighted the importance of choosing an appropriate threshold, as it directly influences the quality of the image treatment. Chen & Wang (2018) developed a machine-vision-based method focusing on locating the viscera of poultry carcasses, including on their discussion the importance of defining a proper threshold.
In this study, no tested global threshold was able to effectively separate the object (bone) from the background, therefore requiring additional tools to eliminate the noise present in the images. The threshold of 0.16 (Fig 3.B) was the one that suited the proposed processing method best. Thresholds below 0.16 (Fig 3.C) increased the amount of apparent noise in the image. In contrast, thresholds above 0.16 (Fig 3.D) classified pixels associated to an initial red coloring (in the original image) of the bones as background. The results obtained regarding the choice of the threshold during the binarization process can be justified with the choice of elements of the image acquisition. As for the background, black ethylene vinyl acetate is a material that has micropores that generate reflection points when in contact with light. Regarding lighting, the fluorescent lights were placed far from the object, thus, allowing a preponderance of shadows in the image. Although the threshold employed at the binarization stage did not adequately separate the object of interest from the background, the noise cleaning processes showed satisfactory results. The algorithm used to fill in regions became useful in cases where dark lighting or shading effects in some areas of the bone were not sensitive to the threshold (≤0.16). As a result of this step (Fig. 3.E), additional regions of bones were identified and all pixels inserted in this outline were classified as belonging to the object (white color).
The last remaining problem was to remove the white dots from the bottom of the images. For this, the morphological operations of this processing method were efficient in eliminating possible points of black background that, due to lighting, were above the threshold used in the binarization of the images (> 0.16). As a result (Fig. 3.F), erosion operations eliminated noise (small white dots) from the bottom. In contrast, dilation (antagonistic operation) returned the remaining parts of the object (in this case, the cut chicken bones) closer to the original dimensions.
Morphological operations are recurrent in studies of human skeleton bones: Tanaka et al. (2001) applied dilation and erosion algorithms for image processing of the third lumbar vertebra; Wu et al. (2016) applied morphological operations to highlight the abdominal region for future liver extraction and evaluation, and Ghosh & Saha (2018) used morphological operations in the initial processing steps of detecting human bone fractures. Thus, expansion and erosion operations have been used to eliminate noise and/or enhance regions in different studies, for which bones were objects of interest.

Results of feature extraction
From the results of the digital processing of the images, it was possible to extract the morphometric characteristics of the broiler bones at different ages (Table 1). When observing the crude averages of the area variable of the tibia, it has to be noted that these increased over an animal's life cycle, from 12904.79 ± 1223.16 pixels for newborn animals (minimum value) to 165243.70 ± 20929.32 pixels for animals at the age of slaughter (maximum value). The same behavior was observed in femur bones, whose averages were between 8160.14 ± 1045.42 pixels (day 0) and 119645.03 ± 15857.07 pixels (day 42). The results are in line with what was expected, in terms of an increase in the area of the locomotor bones with age and the comparison between tibiae and femurs extracted from birds.
When observing the gross pixel averages for the lengths of the chicken bones, it can be observed that the values decreased with the age of the animals, both, for the tibiae and the femurs. The decrease was constant, with maximum averages at the age of 0 days and minimum averages observed at 42 days of rearing. The results obtained are opposed to the bone growth observed by other authors (Barbosa et al., 2010;Reis et al., 2011), who observed an increase in the length of the bones of the tibia and femur throughout the life of the animals.
As for recommendations for a more accurate evaluation of this characteristic, the algorithm to obtain bone length must be reformulated and written in a more sophisticated way. Another option is to perform regression adjustments by comparing values from real samples with those obtained by the program the crude means of the variables follow a linear pattern over the ages.
The perimeters extracted from the bones followed the same pattern as the areas: lower values at age 0, gross averages of 827.79 ± 35.27 pixels for the tibia and 620.35 ± 47.50 pixels for the femur; higher values at age 42, gross means of 3118.22 ± 221.90 pixels for the tibia and 2408.72 ± 86.23 for the femur; steady growth throughout the life cycle; and lower means of the femur compared with the tibia at the same age. When converting the pixel values to real values, i.e. to cm, averages of 12.70 cm (0 days), 19.05 cm (7 days), 25.65 cm (14 days), 34.09 cm (21), 39.18 cm (28 days), 46.19 cm (35 days) and 47.85 cm (42 days) were obtained for the tibia and averages of 9.52 cm (0 days), 14.98 cm (7 days), 20.22 cm (14 days), 27.49 cm (21 days), 29.73 cm (28 days), 35.38 cm (35 days) and 36.97 cm (42 days) for the femur.
It is worth mentioning that this study focuses on the development of a software using computational techniques for the extraction of bone variables from broiler chickens. From this, a series of possibilities have been opened to validate and improve feature extraction algorithms to translate these computational values closer to reality (real value meaning). The lengths of the bones can be easily obtained by manual measurement, with a caliper, for which it is possible to develop models of adjustment between the values given in pixels (of the software) with those obtained by measurements.
No methods were found in the literature for the validation of bone areas and perimeters, which are difficult to measure manually, as there are no studies that offer comparative values of these parameters for broiler chicken bones. Also, new geometric characteristics can be explored based on the segmentation process, according to the interests of users/researchers.
Results of using the software Some practical advantages are associated with the use of the software, in which the entire digital processing algorithm discussed so far has been embedded: (a) the human-machine interface allowed faster processing of the image bank used in this study, by minimizing the time required for performing trivial tasks; (b) the GUIDE design made it possible to monitor the evolution of the stages of digital processing performed on the images, allowing for visual and immediate diagnosis of possible errors and, consequently, an incorporation of adjustments into the algorithm; (c) the save option allows the user to register the processed images, for later consultation; (d) as it is a userfriendly tool, the interface allows professionals and researchers to use the algorithm efficiently, quickly understanding its operation. Several authors, who have used the MATLAB GUIDE for producing software in very diverse fields agree that these tools offer accessible operation features and a friendly environment for potential users (Sari et al., 2021).
The addition of the indirect method (threshold adjustment by the user themselves) arose through the intention to apply this software in future studies, in which capture systems different to the one adopted in this study are used. To assess the applicability of the software, and its dependence on the source of image acquisition, three images from different sources were tested (Fig. 4). FIGURE 4. Image processing from different capture systems using the software: Original images (A, D and G); images processed by the direct method, with fixed binarization (B, E, and H); and images processed by the indirect method, with adjustable binarization (C, F and I).
First, an image captured with the same system proposed in this work -black background and semiprofessional camera -was used as an input source for the software, with the difference of no lightening control (Fig.  4.A). Using the direct method ( Fig. 4.B), it was possible to observe a failure of the algorithm when extracting the bone from the background, as the lighter points of the background were classified as bone (white). In this case, the manual adjustment of the threshold (from 0.16 to 0.10) was enough to improve the segmentation process. The influence of lighting in determining the success of the binarization process has been widely discussed in the literature, especially in image capture systems for which lighting is not standardized.
In the second case study, a lower quality image ( Fig.  4.D) captured by a 13.1 Megapixel mobile device (Samsung, South Korea) was used. The background material was black EVA, and the lighting was natural. In this case, both the bone and the background were clear, when compared with the system developed in this project, thus, resulting in the non-identification of the bone using the direct method (Fig. 4.E). As in the previous case, adjustments in the threshold (0.46, the closest to white so far) were enough to extract the object of interest (Fig. 4.F).
The third example, an extreme case, used an antagonistic collection system which is described in item 2.2: to obtain the image (Fig. 4.G), a wooden surface covered with white paint, uncontrolled natural lighting, and a cell phone camera (13.1 Megapixels) were used. Due to an excess of transparent pixels, both from the fundus and from the bone itself, the fixed threshold of the direct method was not enough to distinguish the object from the fundus (Fig. 4.H). In this case, it was necessary to work on two adjustments: color inversion and threshold adjustment.
As the background was lighter than the bone (as opposed to when using a black background), it was necessary to add an algorithm for the color inversion of the binary pixels. After that, with an adjustment of the threshold to 0.27 the segmentation could be performed. However, it is worth noting that the white background showed worse results than the black background, as it requires more processing steps and because the shadow that the object produces in the background of the image cannot be distinguished. The shadow is included in the segmented object, forming a non-real image of the bone shape (Fig. 4.I).
The applications were evaluated regarding the quality of digital processing and segmentation done by the software. In order for features to be extracted correctly, users must consider the distance between the evaluated bone and the image acquisition device. Future adaptations of the software may incorporate an input field in which the user establishes the object-camera distance, and for which the adjustment is then made automatically.

Bone classification results
It was proposed to use the data extracted from the images (item 3.3) in models for the recognition and classification of chicken bones according to age (7 weeks) and the type of bone (tibia or femur), thus, totaling 14 classes to be evaluated. The artificial neural network proposed in this study used eight neurons in the hidden layer, which was the model that presented the best results in the regressive analysis, considering the training curves (R = 0.74), validation (R = 0.86) and test (R = 0.72). As a model evaluation test, the trained ANN was used to classify data not included in the learning. The results offered by the network were compared with the classifications already known (25% of the entire database). As a result, the accuracy of the neural network in correctly classifying data was determined to be 73%.
In the KNN method developed in this project, the five closest neighbors were used, which presented the best result when compared with other k values. In this model, the accuracy obtained was 64%. Thus, the trained ANN obtained better results than the KNN-5, which is the same result as obtained in other studies in which both classification methodologies were used and compared (Moosavian et al., 2013;Murthy & Meenakshi, 2015).
For both models, it was observed that the classification errors were associated with uncertainties in distinguishing femurs of adult animals from tibias of animals from previous weeks. The explanation for this is that the tibia is longer and has a larger area than the femur (see the morphometric properties of item 3.3), however, with the growth of both over the life cycle, the femur reaches similar geometric characteristics to the tibia of younger birds.
Some alternatives should be considered in future projects for improving the quality of the classification, such as refining the algorithms for extracting characteristics and adding new morphometric parameters. The classification of bones according to their age and type has excellent potential for applications within the poultry production chain and may be incorporated in the future in the identification and diagnosis of locomotor problems of birds throughout the production cycle.

CONCLUSIONS
The vision computer system for extracting the geometric characteristics of broiler chicken bones was developed and properly validated, showing great potential of practical usage. This study is one of the first to propose an automatic method for extracting properties that are difficult to extract manually. The proposed digital processing was able to successfully extract the bones of the tibia and femur at different ages of the chickens. In the image classification processing, the ANN presented a high accuracy, considering the number of evaluative classes. As recommendations, new approaches can be made to the extraction algorithms, either to increase the accuracy of the measured properties or to incorporate new geometric properties. Classification improvements can also be obtained by adaptations throughout the computer vision system (image acquisition, digital treatment, and feature extraction).