Algorithms for phenotyping cows