# Assessing the Homogeneity of Forage Mixtures Using an RGB Camera as Exemplified by Cattle Ratios
## 3 Results
### Processing of the Results Obtained  
When analyzing the mixture through a filter, the feed fluorescence was visible both from the camera image and with the unaided eye.  
To facilitate data processing, we binarized the image based on the selected areas for further analysis. The binarized image is a two-dimensional matrix consisting of zeros and ones, where the ones represent the areas of interest.  
The binarized images were loaded into the Image Region Analyzer app where areas were identified and their characteristics determined. Region parameter tables, such as dimensions, position, and orientation, according to Figure 6, were made with the application:  
The quantity and size of objects in the binarized image allow us to judge the uniformity of feed mixing. Signs were found indicating that the feed was not properly mixed. A qualitative assessment of indicators of signs is reduced to the definition of areas in the points of objects (compound feed) and the calculation of their areas. For this purpose, a unique algorithm was developed for detecting such objects, calculating their area and density.  
Figure 6: Processing of binarized TMR images.  
For the above binarized images of size [N,M] the matrix p(i,j) is used to denote each pixel and the value of coordinates (i,j) in the image, where 0 \(\leq\) i \(<\) N and 0 \(\leq\) j \(<\) M. Pixels p(i-1,j), p(i,j-1), p(i + 1,j) and p(i,j + 1) are adjacent to pixel p(i,j) and are called four adjacent pixels of pixel p(i,j). The four neighboring pixels, together with the pixels p(i-1,j-1), p(i + 1,j-1), p(i-1,j + 1) and p(i + 1,j + 1), are called the eight neighboring pixels of pixel p(i,j). Two points of an object <<>> and <<>> are called four connected (eight connected) if a trajectory exists consisting of the points of the object \(a_{1}\), \(a_{2}\),...,\(a_{n}\) in such a way that \(a_{1}=s\) and \(a_{n}=t\), and for all \(1\leq k\leq n-1\), \(a_{k}\) and \(a_{k+1}\) are four adjacent (eight adjacent) to each other. A point cloud of an object in an image is called a four-connected (eight-connected) component in a binary image if, and only if, any of the two pixels in the set is four-connected (eight-connected). The associated component is the desired object (compound feed). The area of object \(O\), \(S_{O}\), is defined as the number of pixels in object \(O\) and is calculated using the formula:  
\[S_{O}=|\{p(x,y)|p(x,y)\in O\}| \tag{1}\]  
An eight-connected object indicates a denser distribution of compound feed, a four-connected object indicates a less dense distribution. An indicator of unevenness may be the absence of feed particles in any part of the image. To detect such anomalies, the image is divided into nine parts and the area of white areas is summed up in each. Detection of more than 90% of four connected objects evenly distributed across the image indicates high-quality mixing on the feed table. If the difference between the area of the part and the average of the image differs more than the permissible value, this is considered a deviation from the norm:  
\[K=\left\{\begin{array}{ll}1,S_{i}-\sum S_{O}\leq L,\\ 0,\ S_{i}-\sum S_{O}>L.\end{array}\right. \tag{2}\]  
\(S_{i}\) is the average area for the i-th binarized image;  
K is the mixing quality indicator (1 is qualitative, 0 is not qualitative), L is an acceptable value.  
The developed system will allow to introduce control into the final stage of feeding cattle for mixing the components of the feed mixture directly in the feed dispenser robot. The quality control of the mixture will reduce the feeding costs associated with the issuance of an additional amount of compound feed. It will also increase the productive longevity of cattle through a more balanced diet.