key: cord-0057750-u4r3whxf authors: Ho, Harvey; Nordbø, Øyind title: Towards a Generic Bicubic Hermite Mesh Template for Cow Udders date: 2021-03-18 journal: Geometry and Vision DOI: 10.1007/978-3-030-72073-5_8 sha: 0fec41d363aacc9510434268c339d315337125c3 doc_id: 57750 cord_uid: u4r3whxf The shape of cow udders represents an important trait for the functionality and longevity of dairy cows, yet traditional trait definitions cannot fully capture its complexity. In this work we propose a parametric cubic Hermite (CH) based mesh to model the shape of cow udders and teats. The workflow starts from selecting a subset of nodes from the data cloud captured by a depth scanner, and constructing a CH mesh from the nodes. Using a coherent point drifting (CPD) algorithm, the nodes on the mesh are registered from one cow to their counterparts of another cow while preserving the topological coherence of the mesh. This workflow works well for the udder surface when teats are excluded. However, when teats are included in the mesh, misaligned correspondences occur due to data point occlusion and insufficient sampling points. In summary, a first parametric mesh based 3D model has been constructed for the cow udder and teat. We have examined the efficacy of the morphing algorithm, and also the issues to be solved for a statistical cow udder and teat model. The conformations of cow udders represent important traits for dairy cow breeders, because the shape of udders are important for the functionality [1] , health [2] and longevity [3] of dairy cows. Traditionally, the conformation of udders is scored on a discrete scale by a technician, where several conformation traits are assessed. These traits include the attachment angle of the fore udder, the width, height, depth and balance of the rear udder [2] . However, this scoring system carries laborious work and is prone to subjective errors. In addition, the linear traits are not able to capture the curvature information of the udder surface, for which a more sophisticated criterion, and hence modelling methods are required. In recent years, the dairy industry has been using innovative technologies to measure the shapes of udders. For example, depth cameras/scanners are used to obtain three dimensional (3D) data cloud of cow udders [4] . This kind of data cloud contains pixel-based, depth-encoded points in the number of thousands or more, from which a triangular mesh could be constructed to represent the 3D shape of a cow udder. This method, however, is prone to noises and artifacts caused during the scanning process. Furthermore, the complex shape of cow udders require many mesh vertices to represent its full entirety, yet the vertices for teats are often occluded, as we will show later in the paper. Indeed, depth-point-based 3D udder models are rarely reported in literature. Here we suggest that a more succinct geometric representation of 3D geometries, such as a parametric mesh (e.g., of Hermite, splines) may serve the purpose better because a much smaller number of vertices are required [5] . The challenge for a parametric mesh, however, is to represent the udder shape in sufficient details than triangular meshes based upon a subset of available vertices. Among parametric meshes, the cubic Hermite (CH) mesh has been previously used for statistical modelling of the liver [6, 7] , and for modelling the pig surface [5] . In work [7] , a statistical liver model is morphed to subject-specific livers, and the landmark points on the template mesh are automatically fitted onto the target data cloud [6] . The weakness of this algorithm, however, is that the nodes on the CH mesh are not anchored onto feature points of the target data cloud. The correspondence problem could hamper the efficacy of this approach. The aim of the work is twofold. Firstly, we aim to use a parametric mesh to represent the udder surface and the teat. Secondly, we aim to develop a workflow where the mesh vertices can cohesively morph from one udder to another. To that end we will apply a coherent point drifting (CPD) algorithm [8] , which may be classified into a nonlinear registration method. In the following sections we will outline the workflow, and demonstrate its use in developing a generic cow udder template. Cow udder data were retrieved using an Intel RealSense F200 camera, mounted on a selfie stick, and placed underneath cow udders. A colour-coded depth image and its binarised image are shown in Fig. 1 (a) and (b), respectively. Since bovine structures outside cow udders, such as the legs and the background need to be removed, the udder area is manually segmented as a mask (Fig. 1c) . With this mask, only the data points within the udder region are 3D re-constructed. Figure 1 (d) shows the 3D point cloud of a udder in the cartesian coordinate system. The colour coding of the data points represents their distance from a baseline plane (in brown colour), e.g., the red coloured points are further away from the plane than blue coloured points. A CH mesh uses a set of sparsely located nodes to represent a shape [9] . The basis functions for CHM have been introduced in many literatures, e.g., in [9] , therefore are not repeated here. In a surface CH mesh, two material coordinates (ξ 1 , ξ 2 ) define all nodes on the mesh. Figure 2 illustrates the process of constructing a CH mesh. In Fig. 2(a) , from about two thousand data points of Fig. 1(d) , some 12 × 9 nodes across the udder surface were selected. Then, a 11 × 8 mesh was constructed using an open source software CMGUI (https://www.cmiss. org/cmgui), as shown in Fig. 2(a) . Note, in this mesh, the teats were excluded because their geometric representation requires a denser mesh. In Fig. 2(b) , 44 nodes and 42 elements were used to represent a teat and a udder. We aim to morph a CH mesh such as the one shown in Fig. 2(a) to the data clouds of another cow udder. The key is to register the nodes on the mesh to their counterpart points in other udders. This is a non-rigid registration problem and is restated as below: Note, that the number of data points in X, Y need not to be the same. This is a desired feature in our case where Y contains a smaller number of nodes. For instance, the CH mesh of Fig. 2(a) contains 108 nodes, whereas the number of points in data cloud X can be hundreds or thousands. The core of the CPD algorithm is the Gaussian mixture model (GMM) algorithm [8] , where the GMM probability density function is (we refer the interested reader to much more details of the following equations in literature [8] ): And a likelihood function E is minimised: where θ is used to parameterize the GMM centroids. The correspondence between two points y m and x n is obtained by using the posterior probabilities of the GMM centroids: The values for θ, σ 2 are determined from the expectation-maximization (EM) algorithm. The idea is to move the GMM centroids coherently as a group, and to preserve the topology of the mesh nodes. Concerning the implementation of the CPD algorithm, we made use of the source code in MATLAB (Mathworks, USA) provided from literature [10] . The postprocessing software was CMGUI. Using the CH mesh of a udder (ID 0044), shown in Fig. 2(a) where the teats were excluded, we firstly morphed the mesh (ID 0044) as the GMM centroids to the 276 data points of another udder (ID 0055). Figure 3(a) shows the udder clouds of two cows before morphing, which are distinctly distributed in the cartesian coordinate system. Figure 3(b) shows the two data clouds after morphing mesh 0044. Figure 3 (c) provides a detailed view of the nodes on the mesh pre-and post-morphing. It can be seen that the locations of teats, indicated by the red and blue arrows, were successfully tracked. In Fig. 4(a) , the data points of two udders and teats are shown in blue and purple points respectively. The data points of the two teats are of different orientations. After applying the CPD algorithm, as shown in Fig. 4(b) , the data points on the udder surface fitted well. However, the eight points at the apex of the teat dropped to the wall of the teat (indicated by arrows) due to lack of corresponding points on the other teat. There were two reasons causing the problem: (1) the apex of teat is rather small, and thus is difficult to have sufficient data points to fit onto; (2) one side of the teat wall is often occluded, leading to missing data points. Udder conformations are important traits for dairy breeders, due to their importance for the functionality, animal health, and thus, the economy of dairy farmers. Traditional methods for scoring the shape of an udder relies on several linear traits, which are estimated by visual inspections, or measured by a customised meter for teats [11] . The aim of the work was to develop a generic udder template, and to morph such a generic template to data clouds of udders obtained from depth cameras. To serve the purpose, we used a CPD algorithm, where the nodes of the CH mesh are the centroids of GMM, and their corresponding nodes in the data cloud of another udder are selected via a density maximization algorithm. The current pilot work has shown the efficacy of this workflow in modelling the udder surface. The novelty of the work is that it is the first time a parametric mesh has been used to model cow udders. Furthermore, a coupling of a CH mesh and the CPD algorithm captures the landmarkers better than the automatic fitting algorithm described in [7] . The workflow worked well for the udder surface, when teats were not included. To successfully model the teats, one depth camera may not be enough to retrieve the data points of a teat. Multiple cameras could help, e.g. the multiple Kinect system used in [4] . Alternatively, depth images may be taken from several complementary perspectives to complete the whole picture. As mentioned in Introduction, our ultimate goal is to use a generic mesh as a statistical template for the cow udder, where genetic and health trait analysis could be made. Towards that end, the current model needs to be applied to a udder population. By a principal component analysis for the scattering pattern of the mesh, we may be able to identify novel traits for the udder shape [6] . We have developed the first parametric mesh based 3D model for cow udders and teats, and have shown the efficacy of coupling the parametric mesh with a coherent point drifting algorithm. Challenges remain due to eccentric teat shape and occlusion in developing a complete udder and teat model. Lactating dairy cows adapt quickly to being milked by an automatic milking system Genetic parameters of health disorders, and relationships with 305-day milk yield and conformation traits of registered Holstein cows Genetic correlations between longevity and conformation traits in an upgrading dairy cattle population Automated calculation of udder depth and rear leg angle in Holstein-Friesian cows using a multi-Kinect cow scanning system A CT-image based pig atlas model and its potential applications in the meat industry Deformable cubic Hermite mesh templates for statistical liver shape analysis Evaluation of a statistical shape model for the liver Point set registration: coherent point drift Geometric modeling of the human torso using cubic Hermite elements A new point matching algorithm for non-rigid registration Responses of the bovine teat to machine milking: measurement of changes in thickness of the teat apex