From the previous binary image of valleys, the image of distance to valleys can be computed by a method based on mathematical morphology, taking the digital elevation model into account.
Figure 19(a): Image of distances to valleys
(Pixels in black colour are the nearest from a valley)
Figure 19(b): Image of distances to valleys (false colors)