An application of marker-controlled segmentation in petroleum engineering is presented. The images to be segmented originate from high-resolution conductivity measurements of borehole walls. These measurements reflect the composition and structure of the rock formation through which the well was drilled. In this application, we detect and measure small cavities, or vugs, in the walls. We use the tools provided by mathematical morphology. Our strategy is based on gradient image modification using markers and on the watershed transformation. First, the vugs are automatically marked, as well as the background. These markers together delineate areas of interest in which we know there is one contour per vug. To find the vug contour and perform measurements, we modify the gradient image in such a way that only a single edge is kept between the vug and the background markers. We perform the final step of edge detection using the watershed transformation of the modified gradient image. The final result is one closed contour per marked vug. This strategy is presented in detail, experimental results are shown, and artifact elimination is discussed.