Q7Digital Image Processing
Question
Q.4. (a) Apply image Dilation on the following 5x5 input image by using 3x3 cross-shaped structuring element (origin at center): Input image = [[0,1,1,0,1],[1,1,0,0,1],[1,0,0,1,0],[1,1,1,0,1],[1,0,0,0,1]]. Structuring element = [[0,1,0],[1,1,1],[0,1,0]] with origin marked at center. [8]
(b) Discuss image opening morphological operation by writing its mathematical representation. [8]
Answer
Dilating the given 5x5 image with the 3x3 cross-shaped structuring element produces a completely filled all-1s output image, because every 0-pixel in the input has at least one 4-connected (up/down/left/right) neighbor equal to 1; image opening (erosion followed by dilation, A o B = (A minus B) plus B) removes small protrusions while preserving overall object shape.
(a) Numerical: Dilation with a Cross-Shaped Structuring Element
We are given the 5x5 binary image [[0,1,1,0,1],[1,1,0,0,1],[1,0,0,1,0],[1,1,1,0,1],[1,0,0,0,1]] and the 3x3 cross-shaped structuring element [[0,1,0],[1,1,1],[0,1,0]] with its origin at the center. Dilation with this cross-shaped structuring element sets an output pixel to 1 if the pixel itself or at least one of its 4-connected neighbors (up, down, left, right) is equal to 1 in the input image, since the structuring element only includes those five positions (the center plus the four orthogonal neighbors), excluding the diagonal positions.
Verification of the result
Checking every 0-valued pixel in the input image confirms that each one has at least one 4-connected neighbor equal to 1: for example, the 0 at row index 0, column index 0 (top-left corner) has neighbors at (0,1)=1 and (1,0)=1, both equal to 1. The 0 at row index 0, column index 3 has neighbors (0,2)=1, (0,4)=1, and (1,3)=0, and since at least (0,2)=1 and (0,4)=1 are 1, this pixel also becomes 1 after dilation. The 0 at row index 1, column index 2 has neighbors (0,2)=1, (1,1)=1, (1,3)=0, (2,2)=0; since (0,2)=1 and (1,1)=1, this pixel becomes 1. The 0 at row index 4, column index 1 has neighbors (3,1)=1, (4,0)=1, (4,2)=0; since (3,1)=1 and (4,0)=1, this pixel becomes 1. Continuing this check exhaustively across every remaining 0-pixel in the image confirms that in every single case, at least one of the four orthogonal (cross-shaped) neighbors is equal to 1 in this particular densely populated input image.
Since every 0-pixel gets converted to 1 by the dilation operation (because each one has at least one adjacent 1), and every existing 1-pixel obviously remains 1 (the center position of the structuring element also being included), the complete dilated output image consists entirely of 1s across all 25 positions.
- Dilation rule with cross SE: output pixel = 1 if center OR any of up/down/left/right neighbor = 1 in input
- Every 0-pixel in this particular input has at least one 4-connected neighbor equal to 1 (verified exhaustively)
- Therefore every pixel becomes 1 in the output: the dilated image is entirely filled with 1s
- This happens because the input is a densely populated binary pattern where 1s and 0s are closely interspersed with no isolated 0 lacking an orthogonal 1 neighbor
(b) Image Opening
Opening is a morphological operation defined as erosion followed by dilation, both using the same structuring element B, written mathematically as:
The initial erosion step shrinks object A and completely eliminates small protrusions, thin connecting bridges, and isolated noise specks that are narrower than the structuring element, since the structuring element cannot fit entirely within such narrow structures at any position. The subsequent dilation step, using the same structuring element, then regrows the eroded result back outward, restoring the overall size and shape of the larger surviving object regions to approximately their original dimensions.
The net effect of opening is that small protrusions and thin bridges are permanently removed (since they were eliminated in the erosion step and cannot be recreated by the subsequent dilation), while the overall shape and size of larger objects is largely preserved. Opening smooths object contours from the outside, rounding off or removing convex protrusions and sharp outward-jutting corners. It is commonly applied to remove small noise specks from binary images and to separate objects that are touching only through a thin connecting bridge, since that bridge is eliminated by erosion and not restored by the subsequent dilation.
It is instructive to relate this opening definition back to the dilation numerical example in part (a): if the fully-filled all-1s dilation output obtained there were subsequently eroded using the same cross-shaped structuring element, the erosion step would test every pixel's full cross-shaped neighborhood, and since the dilation output is entirely 1s, every neighborhood is trivially satisfied and the eroded result would also be entirely 1s, illustrating that closing (dilation followed by erosion) of an already all-1s image leaves it unchanged, consistent with the idempotence property of closing. Opening, by contrast, applies erosion first; had the original (pre-dilation) input image been eroded first with this same cross-shaped structuring element before any dilation, only isolated pixels whose entire cross-shaped neighborhood was already all 1s would have survived, and the subsequent dilation would regrow only around those surviving points, producing a very different, much sparser result than plain dilation alone, since erosion is highly sensitive to even a single 0 anywhere within the required neighborhood shape.
This full-saturation result, while perhaps visually anticlimactic, is mathematically correct and illustrates an important practical lesson about dilation: the degree to which dilation expands/fills an image depends heavily on both the structuring element's shape/size and the spatial density and distribution of the original foreground (1-valued) pixels - for a sparsely-populated binary image (isolated small objects on a large background), dilation with a small structuring element like this 3x3 cross would produce only a modest, localized growth around each existing object, leaving most of the background unaffected; but for a densely-populated image such as this particular example, where foreground pixels are distributed such that every background pixel happens to be adjacent to at least one foreground pixel, the cross-shaped dilation's neighbor-filling action propagates to fill the entire image. This sensitivity to input image density is an important practical consideration when applying morphological dilation in real image processing pipelines, since applying dilation to an already-densely-populated binary image (such as one containing significant noise or many closely-spaced small objects) can inadvertently merge distinct objects together or saturate large regions of the image, motivating careful pre-processing (such as noise removal via opening) before applying dilation in practice.
This particular numerical example is a useful teaching illustration precisely because its saturated (all-ones) result clearly demonstrates the boundary behavior of dilation under a densely-populated input, complementing the more typical, partial-growth examples usually shown for sparser images, and reinforces that morphological operation outcomes are strongly data-dependent rather than universal.
A practical takeaway for students is to always explicitly verify at least a handful of individual zero-pixel positions against their cross-neighborhood, as done above, rather than assuming a partial or intuitive dilation result, since dense binary images can behave counterintuitively under morphological growth operations.