Q8Digital Image Processing
Question
Q.4. (a) Explain Erosion and Dilation. [8]
(b) Explain - (i) Thickening [4] (ii) Pruning [4]
Answer
Erosion shrinks object boundaries (removing small objects and thin protrusions) while dilation grows object boundaries (filling small holes and gaps), each formally defined via set-translation of a structuring element; thickening adds boundary pixels in a controlled way, while pruning removes spurious spurs left over after skeletonization.
(a) Erosion and Dilation
Erosion is a fundamental morphological operation that shrinks or erodes the boundaries of foreground objects in a binary image. Given a set A (the image) and a structuring element B, the erosion of A by B is formally defined as the set of all points z such that the structuring element B, when translated so its origin is at z, is entirely contained within A.
In practical terms, a pixel z survives erosion (remains part of the foreground in the output) only if every single pixel covered by the structuring element, when centered at z, is also a foreground pixel in the original image A. This causes the overall object to shrink inward from its boundary, and it also causes small objects or thin protrusions (narrower than the structuring element) to be removed entirely, since the structuring element cannot fit completely inside them at any position.
Dilation is the complementary operation that grows or expands the boundaries of foreground objects. Given the same set A and structuring element B, the dilation of A by B is formally defined as the set of all points z such that the reflection of B, translated so its origin is at z, overlaps with A in at least one pixel.
In practical terms, a pixel z becomes part of the foreground in the output if at least one pixel of the (reflected) structuring element, when centered at z, coincides with a foreground pixel in the original image A. This causes the overall object to grow outward from its boundary, and it also causes small holes or narrow gaps (narrower than the structuring element) within or between objects to be filled or bridged, since the expanding structuring element reaches across these small gaps.
(b) (i) Thickening
Thickening is a morphological operation that adds pixels to the boundary of foreground objects in a controlled, structured way, and it is considered the dual (complementary) operation to thinning (which removes boundary pixels in a controlled way to produce a skeleton). Thickening is typically implemented using a hit-or-miss transform-based conditional rule applied iteratively with a sequence of structuring elements, adding pixels only where a specific structural pattern condition is satisfied, rather than uniformly dilating the entire object as ordinary dilation would. It is used to grow objects in a controlled, structured manner, such as connecting nearby line segments or endpoints that should logically form a single continuous structure, without indiscriminately thickening the entire object uniformly the way plain dilation would.
(b) (ii) Pruning
Pruning is a morphological technique used as a post-processing cleanup step, typically applied after a thinning or skeletonization operation has been performed on an object. Skeletonization algorithms often leave behind small, unwanted spurious branches or spurs projecting from the main skeleton structure, caused by minor irregularities or noise along the original object's boundary. Pruning removes these spurious branches, typically by repeatedly identifying and removing the endpoints of skeleton branches for a limited, fixed number of iterations (since a spurious spur is generally much shorter than genuine, meaningful skeleton branches, removing endpoints for only a few iterations eliminates the spurs while leaving the true, longer skeleton branches largely intact). This produces a cleaner, more accurate skeleton representation of the original object's essential shape and topology.
In more detail, the pruning algorithm is generally implemented as a sequence of conditional hit-or-miss transform operations, applied using a specific set of structuring elements designed to detect and remove endpoints (pixels having only a single skeleton-connected neighbor). After a fixed small number k of such endpoint-removal iterations, whatever spur branches were shorter than k pixels in length will have been entirely erased back to their point of attachment on the main skeleton, while branches longer than k pixels will only have been shortened by k pixels from their tips, still leaving the bulk of the genuine branch intact. Because this endpoint-erosion process can also slightly shorten genuine, meaningful branches (not just spurs) by up to k pixels from their very tips, a common refinement is to follow the pruning step with a controlled regrowth step: the endpoints of the surviving pruned skeleton are regrown outward, but only within the original object region (using the original object as a constraining mask so growth does not extend beyond the object's true boundary), restoring the true branch tips to approximately their original length while leaving the removed spurs, which have no remaining stub to regrow from, permanently eliminated.
Both thickening and pruning are typically applied as later-stage refinement operations in a complete morphological image analysis pipeline: thinning (or skeletonization) is first used to reduce an object to a single-pixel-wide skeleton representing its essential topology and shape, pruning is then applied to remove the spurious, noise-induced spurs that thinning algorithms commonly introduce, and thickening may separately be used in scenarios where connected, controlled boundary growth (rather than skeleton extraction) is the goal, such as reconnecting nearby broken line segments detected during an edge-detection or line-extraction stage of processing.
The choice of structuring element shape and size directly determines the specific effect erosion and dilation have on a given image - a larger structuring element produces a correspondingly stronger erosion (shrinking) or dilation (growing) effect, while the structuring element's shape (such as a disk, square, or cross/plus shape) determines the directional characteristics of the resulting shape change, for instance a horizontally-elongated structuring element will erode/dilate more strongly along the horizontal direction than the vertical direction. Both thickening and pruning, discussed in part (b), are themselves built from repeated applications of more elementary hit-or-miss transform operations (a morphological operation using a pair of structuring elements to simultaneously test for foreground and background pattern matches at each pixel location), illustrating how the basic erosion/dilation primitives combine to form the more specialized higher-level morphological operations used throughout practical binary image analysis.
Erosion and dilation are themselves duals of each other with respect to complementation: eroding an image is equivalent to dilating its complement (background) and then complementing the result again, a duality relationship that directly explains why opening (erosion then dilation) and closing (dilation then erosion) are themselves dual operations with respect to foreground and background.