Measuring Pig Travel By Image Analysis

Nabil Brandl1

1Author is Research Scientist in Animal Science at The Danish Institute of Animal Science, Dept. of Animal Health and Welfare, Research Center Foulum, P. O. Box 39, 8830 Tjele, Denmark, e-mail:, HomePge:


An attempt has been made at Foulum Research Center, in Denmark, to measure the travelling distance for each pig within its environment, using image analysis system (a semiautomatic system). These measurements explained the behaviour and pig's conditions. Video analysis had been used to assess the pigs' movement. This method is difficult and costly. The main purpose of this paper was to develop an alternative method in measuring pigs activities without disturbing them. The method had been developed using a computer pc based program, video and image analysis techniques. The program works in two ways, first selected a series of video frames with time laps, then qualified an interactive operator to select points, which locate pigs position on the image, and saved the results on a computer ASCII file for further analysis. Using the saved data to compute the travelling distance for each pig. The material, which had been used was 10 Yorkshire pigs. Half of the pigs were normal, while the second half were dwarf. The results showed pig's pattern of activities in one hour observations. This pattern explained pig's movements surrounding the feeder, sleeping and manure places, which demonstrated the pig's conditions. It concluded that image analysis is a promising method to monitor pigs activities in pigs' houses, as well as monitor activities manually (video analysis), which it recommended to be used in applied ethological studies.

Keywords: Travelling distance, Video techniques, Image analysis, Animal behaviour, Animal locomotion and pigs.


Animal health and welfare can be assessed by measuring its locomotion. Many researchers have confirmed that lack of animal locomotion will indicate lack of welfare. The skeletal system of animal will provide the animal by mechanical strength and calcium/phosphorus contents. Therefore muscles and bones are essential for the normal movement. Any change in normal pattern, will change animal well being. Perrin and Bowland (1977) had investigated the effects of enforced exercise on the incidence of leg weakness in growing boars. They found insignificant effect of exercise. Marchant and Broom (1996), who investigated the effect of dry sow housing conditions on muscle weight and bone strength. They found significance effect, where the sows have more space to move about. Studying movement in pigs houses can be useful to evaluate the animal condition, such as number of time visiting the feeder, or the travel distance. Gonyou (1992) has studied the feeding behaviour. He found that individual pigs spent more time and eating more than pigs kept in groups, while Hsia and Wood-Gush (1983) had found that social facilitation will increase eating time. Christison & deGoodijer (1986) had found that it was much easier for a person to watch the animals and quickly draw on a grid on paper, than it was to record the movements on video camera. The alternative method in measuring the pigs' movement is image analysis. The image analysis techniques provide an alternative method, instead of the manual direct method (video watching). Schwarting et al (1993) had designed an image analysis system to monitor the rats movement, to distinguish between the conditional movement from the unconditional one. Bonatz et al (1987) had proved the validity of image analysis method to monitor the movement of animal, which injected by amphetamine into the brain area (substantia nigra), to detect brain lesions. Also Barber et al (1973) had investigated the rotation behaviour in rats with brain lesions, by designing an electronic apparatus.

The main purpose of this paper was to develop a method for the behaviour tests and observations on pigs, by measuring pigs' activities without disturbing them, using a semiautomatic image analysis system.


Ten pigs of Yorkshire breed have been used to measure their movement. The pigs have descended from one litter, which contains 5 dwarf and 5 normal pigs. The choice of this litter was to test the abnormal movement in the pen. Therefore the dwarf pigs were placed together in one pen (1.53X3.25 m) and the normal pigs placed in another pen with the same size. The pigs were video recording from above. The video frames were gathered on a video tape with normal speed (30 frames per second) for a period of 1 hours in the morning.

Figure 1. Two successive video frames.

Two PC programmes have been used to analyse the video frames (Figure 1). One to subtract images with 4 seconds intervals and storage on pc-disk. The other to measure the travel distance by determining the pigs' positions (x,y co-ordinates), using pc-mouse and software, which was windows-based system. The software was built in a user friendly way, which allowed the users to load the images and click with the mouse to determined the x,y co-ordinates. The x,y co-ordinates were saved automatically on an ASCII file for further analysis. 200 images were collected to represent the most active period for the dwarf and normal pigs (from 8 am to 9 am).

The measuring variable was the travelling distance, which calculated as follows:

D=[ ((x1-x2)2 )+(y1-y2)2)]0.5
D = The travelling distance.
x1= The x-coordinate of the first image
x2= The x-coordinate of the successive image.
y1= The y-coordinate of the first image.
y2= the y-coordinate of the successive image.

Statistical Method

The collected data have been investigated statistically, using TTEST (SAS version 6.11), SAS user (1992). The test was based on variance within and between pigs for total travel distance (dwarf contra normal).

Description of the Software

The software has been designed at Research Center, Foulum in Denmark for the purpose of this paper. The programming language, which was used Pascal Version 7.0, windows based system. It used the object oriented language for developing the pop up menu.

The software, which has used in this paper was based on pop-up menu or dialogue box system. The programme consists of three main pop-up menu; FILE, FORWARD/BACKWARD and METHOD. The FILE menu consists of one sub menu ; IMPORT. This sub menu allow the user to load the BMP image. The menu FORWARD/BACKWARD menu permit the user to load the images forward wise or backward wise. The METHOD menu gives the user two options to run the programme. The first option is tracing a certain point and the second option is finding an object in the image. In this paper the first option (tracing) has been used. The programme can be started by clicking on the menu METHOD to choose the running method. The next step is to click on FILE menu and IMPORT to select the BMP images to be loaded. The programme will ask the user to enter animal ID, which will be saved on the ASCII file. The next step is to click on a certain point in the image and it will be saved automatically the x, y, co-ordinates. By clicking on the right bottom of the mouse, the programme will load the next image. Therefore it was possible for untrained user to analysis 200 images for one pigs in 10 minutes. In this paper it took one and half hours to analyse 200 images for ten pigs. Figure 2. shows the pop-up menu in the software. The software can be downloaded from the author's homepage;


Figure 2. The pop-up menu in the software


When analysing the images, the author found a person with minor experience in computer applications could be very easy detect the animal locomotion. It took 10 minutes to analyse 200 images for one pigs. This is a great advantage compared to the difficult and costly method of video watching.

In Figure 3. showed a general trend of pigs' movement (travel distance), which indicated that pigs with legs problems (Dwarf) were less active than the healthy ones (Normal). This fact was well known before the experiment started. The results had shown that the image analysis method could measure the pigs' activities and distinguish the sick animal from the healthy one. The current software has shown that it was possible to analyse a large number of images in a very short time. Also the software did not need an experienced person in animal behaviour, to measure the pigs' activities.

Figure 3. Average of travelling distance in pixels for dwarf and normal pigs.

In Table 1. shows that the dwarf pigs stand still more than normal pigs, where at 0 distance 73.1% of pigs stand still while 41.1 for normal pigs. On the other hand 6.8% of the normal pigs had moved more than 70 pixels, contra 0.8% of the dwarf pigs.

Table 1. Frequency table of travelling distance for dwarf and normal pigs.

                Dwarf pigs                      Normal pigs

Distance   Frequency            Percent   Frequency   Percent ________________________________________________________________________

0              731                      73.5          407           41.1

10            168                      16.9         236            23.8

20            49                         4.9         103             10.4

30           15                          1.5          61                6.2

40          10                           1.0         47                 4.7

50            9                           0.9         42                 4.2

60            5                           0.5         26                 2.6

70>          8                          0.8         68                 6.8


Total       995                     100         990               100


In Table 2. shows the variation within and between pigs' type. This showed that variance within group was homogenous, while the variance between group was different. Also showed a significant difference between pigs' type (dwarf contra normal) (***P<0.001).

Table 2. Results from Ttest of variance analysis.

Variable: The total travelling distance in pixel.

Type      N      Mean      Std Dev        Std error


Dwarf     5      1143.71    375.71        168.02

Normal   5      3745.46    505.63        226.13


Variance      T        Method          DF      Prob>|T|


Unequal    9.24     Satterthwaite   7.4      0.0001

                           Cochran          4.0       0.0008

Equal       9.24                           8.0       0.0000

For H=: Variance are equal,   F'=1.81    DF=(4,4)       Prob>F' 0.5792



Measuring travelling distance of animals is an important process to assess their health and welfare. Many researchers had proved the importance of measuring travel distance as Christison & deGoodijer (1986) did in measuring foothold in sows. This paper has made an attempt to develop a semiautomatic system for measuring pig's travelling distance, which showed that the pigs with weak legs moved less than the healthy ones. Brann et al (1982) had developed a device for monitoring animal activity under drug effect. Bigelow & Houpt (1987) had observed the feeding pattern in pigs. This paper used the same technique as Bonatzy et al (1987) with some major modifications. Bonatzy's system works only for one animal each time. The semiautomatic system, which has used in this paper allowed the user to measure a certain animal and positions. It concluded that the system is adequate to detect individual animal for their health and welfare.


    Barber D.L., Blackburn T.P. and Greenwood T., 1973, An automatic apparatus for recording rotational behaviour in rats with brain lesions, Journal of Physiology and Behaviour, Vol. 11, pp 117-120, Brain Research publications Inc.

    Bigelow J.A. and Houpt R., 1987, Feeding and drinking patterns in young pigs, Journal of Physiology and behaviour, Vol. 43, pp 99-109.

    Bonatz A.E., Steiner H. and Huston J.P., 1987, Video image analysis of behaviour by microcomputer: categorisation of turning and locomotion after 6-OHDA injection into the substania nigra, Journal of Neuroscience Methods, Vol. 22, pp 13-26.

    Brann N.R., Finnerty M., Lenox R.H. and Ehrlich Y.H., 1982, A device for the automated monitoring of stereotypic behaviour, prog. Neuro-psychopharmacol & Biol. Psychiat. Vol. 6 pp 351-354

    Christison G.I. and deGooijer J.A., 1986, foothold of sows on farrowing crate floors, Livestock Production Science, vol. 15, pp 191-200

    Gonyou H.W., Chapple R.P. and Frank G.R., 1992, Productivity, time budgets and social aspects of eating in pigs penned in group of five or individually, Applied Animal Behaviour Science

    Hsia L.C. and Wood-Gushi D.G.M., 1983, A note on social facilitation and competition in the feeding behaviour of pigs, Animal production, vol. 37, pp 149-152

    Marchant J.N. and D.M. Broom, 1996, Effects of dry sows housing conditions on muscle weight and bone strength, Journal of Animal Science, Vol. 62, pp 105-113.

    Perrin W.R. and Bowland W., 1977, Effects of enforced exercise on the incidence of leg weakness in growing boars, Can. J. Anim. Sci.

    SAS 1992, SAS user guide, SAS Institute inc., Box 8000, Cary, NC, 27512-8000, USA

    Schwarting R.K.W., Goldenberg, Steiner H., Fornaguera J. and Huston J.P., 1993, A video image analysing system for open-field behaviour in the rat focusing on behavioural asymmetries, Journal of Neuroscience Methods, Vol. 49 pp 199-210.