From the previous binary image of ridges, the image of distance to ridges can be computed by a method based on mathematical morphology taking the digital elevation model into account.
Figure 17(a): Distance to ridges
(The pixels in black colour are the nearest from a ridge)
Figure 17(b): Distance to ridges (false colors)