An implement for automatically milking a dairy animal, such as a cow (72), comprises a sensor (24, 28) for forming an image of an observation area, and a milking robot (16) which is operatively connected to the sensor (24, 28), wherein the sensor (24, 28) comprises:a source of radiation (34) for modulated electromagnetic radiation (26, 30 36, 40), a receiver device for radiation (46) reflected by an object (44), sensor image processing means (52),wherein the receiver device comprises a matrix of receivers (50-1, 50-2, 50-3), and the sensor image processing means (52) determine for each of the receivers a phase difference between the emitted radiation (40) and the reflected radiation (46) in order to calculate a distance to the object (44).It is thus possible to obtain a 3D-image, by means of which an improved control between, for example, a teat cup (22) and a teat (62-1, 62-2) becomes possible.