We present the results of numerical simulation for image segmentation based on the chain distance clustering algorithm. The key issue is the use of the p-adic metric, where p > 1 is a prime number, at the scale of levels of brightness (pixel wise). In previous studies the p-adic metric was used mainly in combination with spectral methods. In this paper this metric is explored directly, without preparatory transformations of images. The main distinguishing feature of the p-adic metric is that it reflects the hierarchic structure of information presented in an image. Different classes of images match with in general different prime p (although the choice p = 2 works on average). Therefore the presented image segmentation procedure has to be combined with a kind of learning to select the prime p corresponding to the class of images under consideration.