Comparison of segmentation algorithms for cow contour extraction from natural barn background in side view images

T. van Hertem, V. Alchanatis, A. Antler, E. Maltz, I. Halachmi, A.A. Schlageter Tello, C. Lokhorst, S. Viazzi, C.E.B. Romanini, A. Pluk, C. Bahr, D. Berckmans

    Research output: Contribution to journalArticleAcademicpeer-review

    33 Citations (Scopus)


    Computer vision techniques are a means to extract individual animal information such as weight, activity and calving time in intensive farming. Automatic detection requires adequate image pre-processing such as segmentation to precisely distinguish the animal from its background. For some analyses such as gait analysis, a side view perspective is recommended. When using a side view angle however, the background is more difficult to control – moving objects, such as other animals may negatively impact successful image segmentation. The objective of this research was to evaluate five different background segmentation algorithms on side view images when taken against a static background (a solid transportable wall) and a dynamic background (open air, without a wall). The experiments were conducted on a commercial robotic-milking dairy farm in Israel with a herd size of 70 Israeli Holstein cows. A side view image of cow’s gait was recorded after milking when the cows exited the milking area and returned to the cowshed. From the recording database, a random selection was made of 35 frames containing a static background (solid wall) and 20 frames containing a dynamic background (natural barn environment with other cows). Five segmentation algorithms were chosen and adapted from literature to extract the cow shape from the image. The output of three algorithms gave the cow’s full body shape two identified only the contour of the cow’s body. The algorithms were compared on their ability to correctly identify the cow’s back contour line. The performance of each algorithm was quantified by comparing its outputs to a golden standard of manually labelled cow pixels in the image. The introduction of a physical wall behind the cows (static background) significantly improved the foreground segmentation results (Mean Absolute Error (MAE) = 6.7 ± 5.7 pixels vs. 19.7 ± 9.1 pixels). The fourth algorithm, based on an edge detection on the background difference frame, gave the best cow back contour line segmentation results (b0 = -0.4 ± 15.5 and b1 = 1.00 ± 0.07). The fifth algorithm which is based on consecutive frame differences was less accurate than the other four methods which are based on the background frame differences (MAE = 16.0 ± 5.9 pixels vs. 4.1 ± 2.2 pixels, 4.3 ± 2.2 pixels, 5.6 ± 2.8 pixels and 3.7 ± 1.4 pixels respectively for the other four algorithms). The results show that the applied algorithms were not robust enough to work on side view images with dynamic backgrounds.
    Original languageEnglish
    Pages (from-to)65-74
    JournalComputers and Electronics in Agriculture
    Publication statusPublished - 2013


    • dairy-cattle
    • automatic detection
    • digital images
    • body shape
    • lameness
    • locomotion
    • vision
    • behavior


    Dive into the research topics of 'Comparison of segmentation algorithms for cow contour extraction from natural barn background in side view images'. Together they form a unique fingerprint.

    Cite this