Method of performing an animal related action on an animal part of an animal in an animal space provided with an animal related device (2, 3), the method comprising a step of determining a position in at least one direction of the animal part of the animal, and controlling the animal related device to perform an animal related action on the basis of the provided position of the animal part, the step of determining the position comprising: - obtaining a two-dimensional image of a part of the animal space intended to contain the animal part, and containing depth information by means of a 3D sensor device, - preprocessing the image according to a first preprocessing mode, including noise-reducing the image according to a first noise reduction mode and assigning a group of pixels to the animal part according to a first set of rules, to thereby provide a first preprocessed image with a first image of the animal part, - preprocessing the image according to a second preprocessing mode, including noise-reducing the image according to a second noise reduction mode and assigning a group of pixels to the animal part according to a second set of rules, to thereby provide a second preprocessed image with a second image of the animal part, - comparing the first preprocessed image and the second preprocessed image to obtain at least one image difference, - if the at least one image difference is below or equal to a respective predetermined threshold, processing the first preprocessed image according to a first position determining mode, to thereby provide the position of the animal part, and - if the at least one image difference is above the predetermined threshold, processing the second preprocessed image according to a second position determining mode, to thereby provide the position of the animal part. - obtaining a two-dimensional image of a part of the animal space intended to contain the animal part, and containing depth information by means of a 3D sensor device, - preprocessing the image according to a first preprocessing mode, including noise-reducing the image according to a first noise reduction mode and assigning a group of pixels to the animal part according to a first set of rules, to thereby provide a first preprocessed image with a first image of the animal part, - preprocessing the image according to a second preprocessing mode, including noise-reducing the image according to a second noise reduction mode and assigning a group of pixels to the animal part according to a second set of rules, to thereby provide a second preprocessed image with a second image of the animal part, - comparing the first preprocessed image and the second preprocessed image to obtain at least one image difference, - if the at least one image difference is below or equal to a respective predetermined threshold, processing the first preprocessed image according to a first position determining mode, to thereby provide the position of the animal part, and - if the at least one image difference is above the predetermined threshold, processing the second preprocessed image according to a second position determining mode, to thereby provide the position of the animal part.