Extraction of Chest Girth and Body Length Features to Estimate Goat Weight

Measuring goat weight on a farm is carried out by two methods. The first method conventionally measures the chest girth (CG) and body length (BL), while the second is performed using a scale. This study aimed to facilitate the CG and BL measurements to estimate goat weight more efficiently through image processing. The endpoints of CG and BL were determined automatically using binary large object (BLOB) segmentation. The images of 120 goats were taken at three different shooting distances of 50 cm, 70 cm, and 90 cm. The statistical testing of the three scenarios in this study explained that the ideal distance to take pictures is the basis for determining whether or not the size of the circumference and BL is appropriate as a feature for estimating the weight of goats based on image processing. Statistical analysis showed that the features of CG and BL at a distance of 50 cm and 70 cm were not significantly different from the measurements of CG and BL of goats carried out directly (actual data). In comparison, the results of testing the feature prediction data at a distance of 90 cm are significantly different from the actual data.


Introduction
Among the various types of local livestock, goats are one that is widely kept.Goats are a type of livestock that is quite popular in Indonesia, but the scale of their business is still small, with a traditional maintenance and breeding system.The characteristics of local goats in Indonesia are small, relatively short bodies, and short ears.Both males and females have horns, short necks, and high backs.The average height of adult goats is 60-70 cm, while adult females are 50-60 cm.The live weight of local Indonesian goats is between 20 and 30 kg, and adult female goats are between 15 and 25 kg.
Knowledge and skills of goat breeders in measuring body weight or the achievement of body weight gain in their livestock are one aspect of management that is quite important in the goatrearing business.Measuring the body weight of goats correctly is beneficial for local farmers in determining the right amount of feeding, administering drug doses, and correctly determining the value or price of goats.
The exact body weight of the goat can be determined directly by weighing it on a scale.However, goat scales are only available at specific locations, such as animal markets or slaughterhouses.The goat body weight estimation can be done in 2 ways, namely, estimation ISSN: 0067-2904

Nahari and Alfita
Iraqi Journal of Science, 2023, Vol. 64, No. 10, pp: 5253-5264 5254 using or based on the five senses, but this assessment with the five senses can be very subjective because the results are very dependent on the skill and subjectivity of the appraiser.Another way is to estimate body weight using a correlational formula between body weight and several body dimensions.Estimation using this formula is intended to avoid the nature of subjectivity, resulting in more accurate estimation results.The measurement technique using the correlation formula that breeders widely use is the Lambourne formula.

Literature Review
Previous studies have estimated livestock weight using manual (conventional) parameters of the animal's body (physical measurements).For example, [1] predicted a bare goat's weight by analyzing the linear influence of body measurements and body weight.From the prediction equation and statistical analysis, the study obtained an R 2 = 0.42 and a MSE = 206.09.On the other hand, [2] tested the relationship between body measurements and body weight using the pattern of chest girth and body length with several sheep data mining techniques.The study proved that physical measurements of the goat body could be used to measure goat weight.
The development of computer vision-based technology has helped the efficiency and convenience of various work fields [3][4][5][6].A goat's weight measurement can be done automatically through image processing to help farmers estimate the goat's weight before slaughter [7][8][9].
A study from [10] used computer vision-based technology to estimate the carcass weight of livestock based on the region's growing method and the K-Nearest Neighbor (KNN) algorithm.The study showed that the accuracy of carcass weight measurement was 88.2%, with an average computation time of 61.2 seconds.As a comparison, [11] applied the method of binary large objects (BLOB) and Android-based Support Vector Machine (SVM) multiclass classification to measure the carcass weight of livestock.Surprisingly, the study generated a high level of accuracy in the estimation process and a better computational time of 20 seconds on average.Based on these two studies, it is possible to conclude that segmentation using the BLOB method provides higher accuracy and a shorter computation time than the simple region-growing method.The weakness of previous computer vision-based studies is that the determination of chest girth and body length endpoints was done conventionally [10], [11].Endpoints are the central pixel (drawn in a straight line) that forms the chest girth and body length patterns on the goat image [12].This research will automatically examine the endpoints of chest girth and body length to estimate goat weight using the Pythagorean theorem.Chest girth and body length features obtained from BLOB as an image segmentation method based on region growth are intended to analyze textures more accurately.In other words, using the neighboring and labeling concepts, a BLOB is used to classify a pixel with other similar pixels and then separate the pixels into image parts.
After the goat images were segmented and the endpoints of chest girth and body length were determined, the goat's weight was measured using a Lambourne formula.Therefore, it is necessary to calibrate the image to convert chest girth and body length data into a cm unit.In this research, the images of 120 goats were taken at distances of 50 cm, 70 cm, and 90 cm.

1. Image Segmentation
Segmentation is the process of separating the foreground (objects) and background in an image [13].It has three stages: grayscale, image binarization, and coloring.Grayscale simplifies an image by dividing the intensity of black and white to calculate Red, Green, and Blue (RGB) and continues with image binarization, which means putting black on objects and white on the background.Furthermore, in coloring, the noises in the image are turned into white so that the objects will be well-segmented [14].One method of image segmentation is the Otsu method.The Otsu method is a type of automatic threshold image segmentation in which grayscale digital images are converted to black and white images by comparing threshold and color values in the pixels [15].In 1979, the Otsu method was first introduced by Nobuyuki Otsu [16].
In segmentation, morphology can merge the background points in the object to become part of it [17].Image morphology has several parameters, including dilation, erosion, and filling holes.Filling holes fills the center of a hollow object [18].The next step is labeling to separate some of the pixels that are not interconnected.Pixels in the background are worth 0, while pixels in the objects are worth 1.

2. Binary Large Object (BLOB)
This region's growing image segmentation method accurately analyzes textures [19].Region growing is the process of grouping pixels to form a more extensive region based on predetermined criteria or parameters.This stage has two main parameters: seed initialization and threshold determination.Seed initialization is placed at the center of the image as a possible location of the region of interest (ROI).Threshold determination means finding the area used as a neighbor by determining the neighboring area (NA) to help set the threshold value in the image.

𝐍𝐚 = 𝐖𝐡𝐨𝐥𝐞 𝐢𝐦𝐚𝐠𝐞 − (𝐒𝐞𝐥𝐞𝐜𝐭𝐢𝐨𝐧 𝐈𝐦𝐚𝐠𝐞 )
(1) After knowing the NA, the next step is calculating the neighboring region's mean intensity (MINR).It needs to be done to determine the average pixel intensity in a region.M in the following equation signifies the number of remaining regions, with the notation MINR as the mean intensity of the neighboring region.

𝐌
(2) The mean intensity region (MIR) illustrates the average intensity of a particular (n) region.In other words, the region with the most intensity and length of gray level can be known.N means the number of gray level lengths in the MIR equation, while I implies the gray level intensity.
(3) From the above formulations, an image threshold is obtained, which is denoted by T.  = ( − ) (4) This method distinguishes colors with delicate gradations or the area of adjacent pixels in an image where each pixel has the same logic.Each pixel joined in a BLOB area will be in the front, while the pixels behind will serve as the background and have a 0 (zero) logical value.That means the non-zero pixels are part of the binary object.
BLOB is used to isolate unused objects or different BLOBs.This segmentation method detects pixel dots that contain brightness from the background and unites them into a region.In other words, BLOB groups a pixel with other similar pixels using neighboring and labeling concepts and then separates them into image parts [19].

Method
This research started with receiving inputs and producing outputs.After the estimation results were collected, statistical tests and accuracy calculations were carried out using the Lambourne formula to estimate the weight of the goats.The main focus of this research was determining the features of chest girth and body length in goat images to estimate the goat's weight.
The input system is an image of a goat captured at a distance of 50 cm, 70 cm, and 90 cm.The following process segments the image to separate the object from the background.The segmented goat object is determined by the endpoint value to help measure the goat's chest girth and body length.The line that forms the chest girth and body length is calibrated and converted from pixels to centimeters to calculate the goat weight estimation process using the Lambourne formula.All the processes can be seen in Figure 1, which describes the stages of this study.

Extraction of Chest Girth and Body Length endpoints
As an initial step to determining the endpoint of chest girth and body length in a segmented image, it can be started by determining the endpoint of chest girth circumference in Figure 2.

Goat Weight Estimation
The goat's weight can be estimated using Lambourne's formulation.The Lambourne formula determines livestock weight through two parameters: chest girth (CG) and body length (BL).As seen in Figure 4, body length is the length from the shoulder to the sitting bone (E-C), and chest girth goes circled from behind the shoulder bulge to the back of the forelegs (B-D) [20].
Here is the modified (Lambourne) formula:

Calibration
The results of the image (pixel) measurement must be calibrated to get the actual size.The goal is to know how many centimeters each pixel represents in actual size.The first step in image calibration is to retrieve five data samples and then calculate the average value of those samples.A calibration value will be obtained by comparing the original size (in cm) with the image size (in pixels).Calibration is acquired by multiplying the image size (in pixels) by the calibration value.

Evaluation
Evaluation of the weight estimation model in this research is found by comparing the chest girth parameter and body length parameter from the system with parameter values derived from actual measurements (directly on goats).
A statistical test verifies the difference between the two groups (predicted and actual data).This measurement is carried out to test a hypothesis if there are no assumptions about the distribution of parameters.In other words, the test is a null hypothesis test, which means that there is no real difference between the two data groups and the data are drawn from unrelated samples.The robustness criterion in this test can be considered substantial if the practical level of α e error is in the interval of 0.5α ≤ α e ≤ 1.5α where α is a significance level [21].

1. Dataset
The input used is a goat image of size 3264 x 2448 pixels.As many as 120 goats were observed and divided into three groups according to the shooting distances (50 cm, 70 cm, and 90 cm).The data were collected from "TN GROUP" goat and cow farms in Jalan Raya Karangnongko Km. 6, Sukodono, Pekarungan, Sidoarjo Regency, East Java Province, Indonesia.

2. Feature Extraction to determine Chest Girth (CG) and Body Length (BL)
In this stage, the chest girth and body length endpoints on the segmented image are set.The results of chest girth and body length endpoint determination are presented in Figure 7.The pixel values in the chest girth and body length variables were calibrated and converted into cm units.After obtaining the calibration results for chest circumference and body length, the weight calculation process is carried out using the Lambourne formula in equation 6.The output of this system is the estimated weight of the goat.

3. Statistical Test
In this study, the data obtained were not regular and not homogeneous, so a Mann-Whitney test was used for a statistical test.This test was carried out to determine the influence of image processing based on conventional chest girth and body length measurements.
The first test was carried out on data taken at a distance of 50 cm.In Table 1, the shapes of the distribution of chest girth for the two groups were similar.It could conclude chest girth for predicted data (Mdn = 55.83) and actual data (Mdn = 55.50).The U-values are calculated by adding the predicted and actual data rank sums: U (NPredicted = 40, Nactual = 40) = 772.00.For larger samples, the normal distribution can be used as an approximation.So, in the first test, taking the exact value, the z distribution generates z = -0.270and p > 0.05.Parameter p denotes the difference between the medians.The p-value is more significant than the significance level (0.788), meaning there is no statistically significant difference in the continuous outcome variable between the two independent groups.While the shapes of the distribution of body length for the two groups were similar too.It could conclude that the median body length for predicted data (Mdn = 54.75) and actual data (Mdn = 57.00)was statistically not significantly different, where U-values = 673 with z-score from normal distribution =-1.223 and the difference between the median p = 0.221.It is greater than the significance level ( >0.05).The second test was carried out using data taken at a distance of 70 cm.In Table 2, the shapes of the distribution of chest girth for the two groups were similar.It could conclude chest girth for predicted data (Mdn = 54.50) and actual data (Mdn = 55.50).The U-values are calculated by adding the predicted and actual data rank sums: U(NPredicted = 40, Nactual = 40) = 733.00.In the second test, take the exact value; here the z distribution generates z = -0.645and p > 0.05.The p-value is greater than the significance level (0.519), meaning there is no statistically significant difference in the continuous outcome variable between the two independent groups, while the shapes of the distribution of body length for the two groups were similar too.It could be concluded that the median body length for predicted data (Mdn = 56.62)and actual data (Mdn = 57.00)were statistically not significantly different, where U-values = 711 with a z-score from a normal distribution = -0.857and the difference between the median p = 0.391 is greater than the significance level ( >0.05).The last test was carried out on data taken at a distance of 90 cm.In Table 3, the shapes of the distribution of chest girth for the two groups were not similar, and it could be concluded that chest girth was the same for predicted data (Mdn = 49.47) and actual data (Mdn = 55.50).The U-values are calculated by adding the predicted and actual rank sums: U(NPredicted = 40, Nactual = 40) = 487.00.In the last test taken the exact value, here the z distribution generate z = -3.0.13 and p < 0.05.The p-value less than the significance level (0.003), which means there is a statistically significant difference in the continuous outcome variable between the two independent groups.In comparison, the shapes of the distribution of body length for the two groups were not similar.It could conclude that the median body length for predicted data (Mdn = 52.96)and actual data (Mdn = 57.00)was statistically significantly different, where U-values = 554 with z-score from normal distribution = -2.370and the difference between the median p = 0.018 and it is less than the significance level ( <0.05).

4. Goat Weight Estimation Accuracy
After obtaining chest girth and body length calibration results, the weight calculation process was continued with the Lambourne formula (6).The output of this system is the estimated weight of the goats in kilograms (kg).

Figure 8 : Goat Weight Estimation Accuracy
The level of error in this estimated weight of the goats was measured using the Root Mean Square Error (RMSE) method, where the RMSE can range from 0 to ∞. RMSE can be negatively oriented, where a lower value indicates a better value [22].If the RMSE value is small, it means that the predicted value (predicted data) is close to the observed value (actual data), and vice versa [23].Figure 8 shows that the result of the weight estimation with the second dataset (camera distance 70 cm) has the lowest value, 4.7497.While the worst RMSE value of 5.9502 is found in the third test dataset at a camera distance of 90 cm.

Conclusion
In conclusion, this study aimed to provide farmers with a simple and reliable image processing method for estimating the BW.Estimating goat weight in image processing is tedious and involves segmentation, feature extraction, and calibration.This study proposes a methodology for finding a feature extraction method for estimating goat weight.In the feature extraction step, the Pythagorean theorem supports points to form the right triangle.To estimate goat weight from BL and CG, the Lambourne formula is used.
As a comparison of the results of the estimated weight of the goats measured through conventional techniques with measurements based on image processing, calculations were carried out to see the relative level of the calculation results of the two measurements.
The results of this study prove that different lighting and background shooting distances affect the segmentation results and determine the endpoint.The most accurate goat weight estimation results occur in the second data set (70 cm distance) because it produces the lowest RMSE value (closer to 0) than other test scenarios.
A significant difference between the two groups was found in the last dataset.As for the first and second datasets, there was no significant difference between the two groups.Therefore, these two scenarios showed that image processing-based and conventional chest girth and body length determination were not significantly different.It can be concluded that the body length and chest girth extracted from the image processing process can be used as features to estimate the weight of goats.
Compliance with ethical standards 1) Conflict of interest: The authors declare that they have no conflict of interest.2) Ethical approval: All institutional and national guidelines for the care and use of laboratory animals were followed.

Figure 4 :
Figure 4: Determine Chest Girth and body Length Endpoints of Goath BL = Body Length (cm) CG = Chest Girth (cm) 10840 = provision of the Lambourne formula

Figure- 5
Input Image of the Goat, (a) Distance of 50 cm; (b) Distance of 70 cm; (c) Distance of 90 cm At the BLOB detection-based image segmentation stage, a goat foreground object is generated, as shown in the image below:

Figure 6 :
Figure 6: Binary Large Object Results

Figure 7 :
Figure 7: Chest Girth and Body Length Endpoints

Table 1 :
Test Statistics ( Distance of 50 cm)

Table 2 :
Test Statistics ( Distance of 70 cm)

Table 3 :
Test Statistics ( Distance of 90 cm)