CSE 4227 · Chapter 9 · Deck 11

Morphology I, from zero

Erosion, dilation, opening, closing and boundaries in plain words, with every slide example and past question solved in answer-script form and a pixel-by-pixel simulator next to each.

★ Must study on this page

Start here: what morphology is

slides 3–10On study list
In plain wordsMorphology works on shapes in a black-and-white image. You slide a small stamp, the structuring element (SE), over the image and ask one yes/no question at every pixel: does the stamp fit inside the object here, or does it touch the object? The answers shrink, grow, clean or outline the shapes.

Slide 3. Morphological image processing is used to extract image components for representation and description of region shape, such as boundaries, skeletons and the convex hull.

Slide 4. It relies only on the relative ordering of pixel values, not on their numerical values. We probe the image with a small shape or template called a structuring element. The language of mathematical morphology is set theory.

Slide 5. Morphology applies simple rules and shapes (squares, circles, diamonds, cubes, spheres) to process images. The objective is usually to identify features of interest, as a prelude to high-level inspection or machining. Two kinds: binary morphology and grey-level morphology. Four basic operations for binary images: erosion, dilation, opening and closing.

Slide 6. Binary image convention: each pixel is 0 or 1; foreground (object) = 1 (white), background = 0 (black).

Structuring element (slides 7–10)

A structuring element is a small image or template, a small binary array, that produces a new image from the old one. It is a shape mask used in the basic morphological operations. It can be any shape and size that is digitally representable (box, hexagon, disk, any shape), and each has an origin.

It works as a moving window, so non-rectangular shapes are stored as rectangular arrays (padded with 0s). For simplicity we use rectangular SEs with their origin point; the origin can be at the middle or at any position, and by default it is at the centre.

111
111
111
3×3 square
010
111
010
3×3 cross (the slides' usual SE)
00100
01110
11111
01110
00100
5×5 diamond
111
111
111
3×3 square, origin bottom-right

Fit, hit and miss

slides 11–13On study list

Slide 11. Put the SE on the image:

All morphological processing operations are based on these simple ideas: erosion uses fit, dilation uses hit.

Slide 12. Fundamentally, morphological processing is very like spatial filtering: the SE is moved across every pixel and gives one pixel of the new image, whose value depends on the operation performed. The two basic operations are erosion and dilation.

Slide 13 · fitting and hitting with s1 and s2solved

Fill in the fit/hit table for the three positions A, B, C of the binary image, with s1 = 3×3 square and s2 = 3×3 cross (origin at the centre).

000000000000
000110000000
001111100000
011111110000
011111110000
001111110000
001111111000
001111111110
000001111110
000000000000
the image; A, B, C are the 3×3 windows centred at (6,3), (2,3), (2,8)
111
111
111
window A
011
111
111
window B
000
000
100
window C
111
111
111
s1
010
111
010
s2
positionfit s1fit s2hit s1hit s2
Ayesyesyesyes
Bnoyesyesyes
Cnonoyesno

A is all 1s, so both fit and both hit. B has a 0 in one corner: the square does not fit (that corner), but the cross does (it ignores corners). C has a single 1 in a corner: the square hits it, the cross misses it completely.

Erosion

Must studyslides 14–44Came in past papers
In plain wordsErosion keeps a pixel only if the whole SE fits inside the object when centred there. Pixels near the edge fail, so the object loses its outer layer: it shrinks. Tiny specks smaller than the SE vanish completely.

Slides 14–15. Erosion shrinks the object: it shrinks the foreground and enlarges the background. One of its simplest uses is eliminating irrelevant details from a binary image.

Slide 16. Definition 1 (does the SE fit the set?). Erosion of a set A by SE B is the set of all points z such that B translated by z is contained in A:

A ⊖ B = { z | (B)z ⊆ A }

Slide 17. Definition 2. The SE s is positioned with its origin at (x, y) and the new pixel value is

g(x,y) =
1
if s fits f
0
otherwise

Slide 18. How to compute: for each foreground pixel (the input pixel), superimpose the SE so that its origin coincides with the input pixel. If every SE pixel lies on a foreground pixel of the image, the input pixel stays as it is; if any of them lies on background, the input pixel is set to background.

Slides 19–26 · 1-D erosionworked

Input 1 0 0 0 1 1 1 0 1 1, SE [1 1 1] with the origin at the centre. At each position take the minimum of the three values under the SE (superimpose and multiply: all three must be 1). The two end pixels are ignored.

position12345678
window1 0 00 0 00 0 10 1 11 1 11 1 01 0 10 1 1
minimum00001000

Output: 0 0 0 0 1 0 0 0. Only the middle of the 1 1 1 run survives.

Try it, step by step: the 1-D example, position by position (switch the menu to dilation for slides 50–57).

Slides 27–38 · Erosion example 1 (8×8, cross SE)worked
00000000
00011100
00111100
01111000
01110000
01110000
00000000
00000000
original
010
111
010
SE (origin centre)
00000000
00000000
00011000
00110000
00100000
00000000
00000000
00000000
A ⊖ B

Only 5 pixels keep the whole cross inside the object. Every boundary pixel had at least one cross arm on background.

Try it, step by step: erosion example 1, every one of the 64 positions (slides 27–38).

Slide 39. Erosion can split apart joined objects and strip away extrusions. Watch out: erosion shrinks objects.

Slide 40. Typical uses: removes isolated noisy pixels; smoothes the object boundary (removes spiky edges); removes the outer layer of object pixels, so the object becomes slightly smaller (sets contour pixels to the background value).

Slide 41. Effects: shrinks the size of foreground (1-valued) objects; smoothes object boundaries; removes small objects. Rule: in a binary image, if any pixel in the neighbourhood defined by the SE is 0, the output is 0.

Slide 42. Eroding four times with an 11-pixel disk: the hole in the middle of the square grows as the border shrinks. A disk SE tends to round concave boundaries but preserves the shape of convex boundaries.

Slides 43–44 · Exercise: count the coinssolved

Count the number of coins in the given image by performing an erosion operation.

  1. Binarize the image (threshold): coins become white blobs on a black background. Many coins touch each other, so they form joined blobs.
  2. Erode with a disk SE large enough to break the narrow necks where coins touch. Each coin shrinks to a smaller, separate blob.
  3. Use connected-component labeling to count the separate blobs: the count equals the number of coins.

Dilation

Must studyslides 45–63Came in past papers
In plain wordsDilation turns a pixel on if the SE centred there touches the object anywhere. Every object grows by a layer as thick as the SE arm: it grows, small holes fill up and nearby pieces join.

Slides 45–46. Dilation grows the object: it enlarges the foreground and shrinks the background. It takes two inputs: the binary image to be dilated and the SE (kernel) that decides the behaviour.

Slide 47. Definition 1 (does the SE hit the set?). Dilation of A by B is the set of all z such that the reflected B̂, translated to z, overlaps A by at least one element:

A ⊕ B = { z | (B̂)z ∩ A ≠ ∅ }

Slide 48. Definition 2:

g(x,y) =
1
if s hits f
0
otherwise

Slide 49. How to compute: for each background pixel, superimpose the SE with its origin on the input pixel. If at least one SE pixel coincides with a foreground pixel, the input pixel becomes foreground; if all of them are background, it stays background. (B̂ = B for the symmetric square and cross, so you can skip the reflection.)

Slides 50–57 · 1-D dilationworked

Same input 1 0 0 0 1 1 1 0 1 1, SE [1 1 1]. Now take the maximum of the three values under the SE (border pixels ignored).

position12345678
window1 0 00 0 00 0 10 1 11 1 11 1 01 0 10 1 1
maximum10111111

Output: 1 0 1 1 1 1 1 1. Only position 2, whose window 0 0 0 has no 1 at all, stays 0.

Slide 58 · Dilation example 1 (same image, cross SE)worked
00000000
00011100
00111100
01111000
01110000
01110000
00000000
00000000
original
010
111
010
SE
00011100
00111110
01111110
11111100
11111000
11111000
01110000
00000000
A ⊕ B

The dilated pixels (the slide's green cells) are A ⊕ B − A: 16 new pixels, one layer all round.

Try it, step by step: dilation example 1, every position.

Slide 59. Bridging gaps: a low-resolution text with broken characters, dilated with the 3×3 cross [0 1 0; 1 1 1; 0 1 0]: the broken segments were joined.

Slide 60. Dilation can repair breaks and repair intrusions. Watch out: dilation enlarges objects.

Slide 61. Edge detection: 1. dilate the input image; 2. subtract the input image from the dilated image; 3. edges remain.

Slide 62. Typical uses: fills in holes; smoothes object boundaries; adds an extra outer ring of pixels onto the object boundary, so the object becomes slightly larger.

Slide 63. Effects: expands the size of foreground objects; smoothes object boundaries; closes holes and gaps. Rule: if any pixel in the neighbourhood defined by the SE is 1, the output is 1.

Duality (slides 64–70, formula only)

(A ⊖ B)c = Ac ⊕ B̂     (A ⊕ B)c = Ac ⊖ B̂

Dilation and erosion are duals: one can be written in terms of the other (they are not opposites). We can obtain the erosion of A by dilating its background Ac with the same SE and complementing the result.

Opening and closing

Must studyslides 71–117Came in past papers
In plain wordsOpening = erode, then dilate. Erosion deletes anything too small for the SE; dilation then grows what's left back to its size. Small specks and thin bridges are gone for good. Closing = dilate, then erode: dilation fills small holes and gaps, erosion trims the object back to size. The holes stay filled.

Slide 71. Combinations of erosions and dilations give more interesting compound operations; the most used are opening and closing.

Slides 72–73. Opening of A by B, A ∘ B, is an erosion followed by a dilation:

A ∘ B = (A ⊖ B) ⊕ B
Slides 74–87 · Opening example (cross SE)worked
00001110
00001110
00001110
00011000
01110000
01110000
01110000
00000000
original A
010
111
010
SE
00000000
00000100
00000000
00000000
00000000
00100000
00000000
00000000
step 1: A ⊖ B
00000100
00001110
00000100
00000000
00100000
01110000
00100000
00000000
step 2: (A ⊖ B) ⊕ B = A ∘ B

Erosion leaves only the two centres where the whole cross fits, (1,5) and (5,2). Dilation puts a cross back on each. The narrow link between the two blobs (row 3) and the blob corners are gone: they were thinner than the SE.

Try it, step by step: the slide 74–87 opening: erosion pass, then dilation pass. Use “Next phase” to jump between them.

Slides 88–92. Effect of opening:

Examples: the letter j with noise specks loses the tiny spots without changing its core size. Opening a lines-and-circles image with an 11-pixel disk separates the circles from the lines: the lines are almost completely removed, the circles stay.

Slides 93–94. Closing of A by B, A • B, is a dilation followed by an erosion:

A • B = (A ⊕ B) ⊖ B
Slides 95–108 · Closing example (cross SE)worked
00000000
00001110
00001110
00000000
01110000
01110000
01110000
00000000
original A
010
111
010
SE
00001110
00011111
00011111
01111110
11111000
11111000
11111000
01110000
step 1: A ⊕ B
00000000
00001110
00001110
00011000
01110000
01110000
01110000
00000000
step 2: (A ⊕ B) ⊖ B = A • B

Dilation joins the two blobs across the gap. Erosion shrinks them back to their original outlines, but the new pixels (3,3) and (3,4) in the gap survive: closing bridged the gap without growing the objects.

Try it, step by step: the slide 95–108 closing: dilation pass, then erosion pass.

Slides 109–113. Effect of closing:

Examples: closing with a 22-pixel disc closes the small holes in the foreground (pizza image); threshold a telephone photo, then close with a disc of size 20 to fill the reflections.

Slide 114 · Exercise: which one should we apply here?solved

The input map of Africa (white land) has black text "Northern Africa", "South Africa" written on it; the output is the solid white shape. Which operation was applied?

Closing. The black letters are small dark holes and gaps inside the white foreground. Dilation fills them (the SE touches the white on both sides of each stroke), and the following erosion restores the coastline, so the outline and the size of the continent are unchanged. Opening would not remove holes.

Slide 115. Applications of morphology: noise removal in scanned documents; medical imaging (blood vessel extraction); industrial inspection (defect detection); computer vision (object segmentation).

Slide 116. Opening is the dual of closing: opening the foreground pixels with a particular SE is equivalent to closing the background pixels with the same element. (A ∘ B)c = Ac • B̂.

Boundary extraction and edge detection

Must studyslides 118–121Came in past papers

Slides 118–120. Contours can be extracted by subtracting the eroded image from the original. First erode A by B, then take the set difference between A and the erosion. The thickness of the contour depends on the size of the SE.

β(A) = A − (A ⊖ B)

Slide 121. Edge detection by dilation: (A ⊕ B) − A gives the pixels just outside the object (outer edge).

Fall 25 quiz (set C) Q27 marks

Construct a 6×6 binary image A and a 3×3 structuring element B. Using fundamental morphological operations, formulate an edge-detection algorithm for A with B, and demonstrate the procedure systematically with mathematical expressions.

Choose A = a 4×4 square in a 6×6 image; B = 3×3 square, origin at the centre.

000000
011110
011110
011110
011110
000000
A
111
111
111
B

Algorithm (inner boundary): 1. erode: A ⊖ B = {z | (B)z ⊆ A}; 2. subtract: β(A) = A − (A ⊖ B) = A ∩ (A ⊖ B)c.

Step 1: B fits only where the pixel and all 8 neighbours are 1, i.e. the inner 2×2. Step 2: removing those from A leaves the one-pixel ring.

000000
000000
001100
001100
000000
000000
A ⊖ B
000000
011110
010010
010010
011110
000000
β(A) = A − (A ⊖ B)

Alternative (outer edge): (A ⊕ B) − A, dilation then subtraction, gives the ring just outside the square:

111111
111111
111111
111111
111111
111111
A ⊕ B
111111
100001
100001
100001
100001
111111
(A ⊕ B) − A

Try it, step by step: both edge algorithms: erode then subtract, or dilate then subtract.

Set basics (glance)

slides 123–130Know in 2 lines

Numeric past questions, solved in full

Must studyslides 16–121Came in past papers

Convention used: outside the image counts as background (0). Write the set definition before each operation; it earns the equation marks.

SP22 Q4(b) · F23 Q2(d) (same image)8 / 6 marks

F (5×6) and B = 3×1 vertical [1; 1; 1] with the origin at the centre. Compute (i) the reflection of B (ii) F ⊕ B (iii) Fc ⊖ B (iv) (F ⊕ B) − F (v) the opening of F by B (vi) the closing of F by B, with equations.

000001
001110
011110
011100
100000
F
1
1
1
B (origin centre)

(i) B̂ = {w | w = −b, b ∈ B}. B = {(−1,0), (0,0), (1,0)} → B̂ = {(1,0), (0,0), (−1,0)} = B. B is symmetric about its origin, so B̂ = B.

(ii) F ⊕ B = {z | (B̂)z ∩ F ≠ ∅}: a pixel becomes 1 if it, the pixel above or the pixel below is 1.

001111
011111
011110
111110
111100
F ⊕ B

(iii) Fc ⊖ B = {z | (B)z ⊆ Fc}: complement F, then keep a pixel only if it and both vertical neighbours are 1 in Fc.

111110
110001
100001
100011
011111
Fc
000000
100000
100001
000001
000000
Fc ⊖ B

(iv) (F ⊕ B) − F = the pixels added by the dilation (an outer edge above and below the object):

001110
010001
000000
100010
011100
(F ⊕ B) − F

(v) F ∘ B = (F ⊖ B) ⊕ B:

000000
000000
001100
000000
000000
F ⊖ B
000000
001100
001100
001100
000000
F ∘ B

(vi) F • B = (F ⊕ B) ⊖ B:

001111
011111
011110
111110
111100
F ⊕ B
000000
001110
011110
011100
000000
F • B

Notice: the opening kept only the columns where the object is at least 3 pixels tall (columns 2–3), so everything thinner than B vertically is gone. The closing kept the whole object; the two isolated pixels (0,5) and (4,0) disappeared because they sit on the image border, where the erosion needs the pixel outside the image, which counts as 0.

Try it, step by step: SP22 / F23: every part, switch the Operation menu.

SP23 Q1(a)3 + 2 + 2 + 2 marks

Images X and Y are given. (i) Design a structuring element B so that Y = X ⊕ B; mark the origin. (ii) Write the mathematical expression of the dilation. (iii) Erode Y with the same SE and show the eroded image. (iv) Explain erosion mathematically.

000000
000110
000000
000000
001000
000100
000010
X
011110
011100
000000
101000
110100
011010
001100
Y

(i) Take an isolated pixel of X, e.g. (6,4). In Y it has become (5,4), (6,3), (6,2), (5,2), and (6,4) itself is gone. So B holds the offsets (−1,0), (0,−1), (0,−2), (−1,−2) relative to its origin, and the origin itself is not part of B (value 0). Every other pixel of X gives the same pattern, which confirms it.

101
110
B (2×3), origin = bottom-right cell, value 0

Check: X ⊕ B reproduces Y exactly.

(ii) X ⊕ B = {z | (B̂)z ∩ X ≠ ∅} = {x + b | x ∈ X, b ∈ B}.

(iii) Y ⊖ B = {z | (B)z ⊆ Y}: z survives only if all four offsets from z land on 1s in Y.

000000
000110
000000
000000
001000
000100
000010
Y ⊖ B

Here Y ⊖ B gives back X exactly (this image is lucky; in general (X ⊕ B) ⊖ B is the closing, which can also fill gaps).

(iv) A ⊖ B = {z | (B)z ⊆ A}: the set of all origin positions z where the SE translated by z lies completely inside A. Equivalently, g(x,y) = 1 if B fits A at (x,y), else 0.

Try it, step by step: SP23 (i): X ⊕ B gives Y. The SE is not symmetric, so watch the reflected cells.

Try it, step by step: SP23 (iii): Y ⊖ B.

SP24 Q3(c)2 + 2 + 4 marks

Binary image of the Greek letter θ. Which morphological operation(s) turn θ into the digit 0? Four SEs are given: SE1 horizontal 1×2, SE2 cross, SE3 vertical 2×1 (origin + below), SE4 vertical 3×1. Use any as many times as needed; explain the choice and show the outputs.

0001111000
0011111100
0110000110
0110000110
0110000110
1100000011
1111111111
1100000011
0110000110
0110000110
0110000110
0011111100
0001111000
θ (13×10)

What must go: the middle bar (row 6) is only 1 pixel tall. Every part of the ring is at least 2 pixels thick in the vertical direction. So an opening with SE3 (vertical, 2 pixels) removes the bar and keeps the ring: θ ∘ SE3 = (θ ⊖ SE3) ⊕ SE3.

Why not the others: SE1 is horizontal and the bar is long horizontally, so the bar survives. The cross (SE2) needs 3 pixels in both directions, which also deletes the thin ring corners. SE4 needs 3 pixels vertically, which deletes the 2-row top and bottom of the ring.

Step 1, erosion θ ⊖ SE3 (keep a pixel only if it and the pixel below are both 1). Step 2, dilation by SE3 (put back the pixel below every survivor).

0001111000
0010000100
0110000110
0110000110
0100000010
1100000011
1100000011
0100000010
0110000110
0110000110
0010000100
0001111000
0000000000
θ ⊖ SE3
0001111000
0011111100
0110000110
0110000110
0110000110
1100000011
1100000011
1100000011
0110000110
0110000110
0110000110
0011111100
0001111000
θ ∘ SE3 = the digit 0

Try it, step by step: SP24: the opening with SE3, both passes.

Theory questions, answer-script form

Must studyslides 4–117Came in past papers
SP25 Q1(f)4 marks

Define dilation mathematically for a binary image. Explain the opening and closing operations. What happens when you apply closing to an image with small holes?

Dilation: A ⊕ B = {z | (B̂)z ∩ A ≠ ∅}: the set of all displacements z such that the reflected SE B̂, translated to z, overlaps A in at least one pixel. It grows objects, fills small holes and bridges gaps.

Opening A ∘ B = (A ⊖ B) ⊕ B, an erosion followed by a dilation: removes objects and protrusions smaller than B, breaks thin bridges and smooths the outline, without changing the size of the remaining objects.

Closing A • B = (A ⊕ B) ⊖ B, a dilation followed by an erosion: fills small holes and gaps, joins nearby objects, and smooths indentations, again without changing the core size.

Closing on small holes: the dilation fills every hole smaller than B (the SE reaches the object on all sides of the hole); the following erosion shrinks the object back to its original outline, but the filled holes cannot reopen because the SE now fits there. So the small holes disappear and the object's size and boundary stay the same (e.g. the pizza image closed with a 22-pixel disc).

SP24 Q1(c) · SP22 Q4(a) · Fall 25 quiz (set C) Q13–5 marks

Give the equations of erosion and dilation; describe opening and closing. / Describe two basic morphological operations with equations, effects and applications. / Define dilation and erosion in binary images; how do they affect object size and shape?

Erosion A ⊖ B = {z | (B)z ⊆ A}: a pixel stays 1 only where the SE fits inside the object. Effects: shrinks foreground objects (removes the outer layer), removes objects smaller than B, smooths the boundary by cutting spikes, can split touching objects, enlarges holes. Uses: removing isolated noise pixels, separating touching coins before counting, boundary extraction β(A) = A − (A ⊖ B).

Dilation A ⊕ B = {z | (B̂)z ∩ A ≠ ∅}: a pixel becomes 1 where the SE hits the object. Effects: expands foreground objects (adds an outer layer), fills small holes, bridges gaps, joins nearby objects, smooths intrusions. Uses: repairing broken characters in low-resolution text, filling holes, edge detection (A ⊕ B) − A.

Size and shape: erosion makes objects smaller and thinner (size shrinks by the SE radius); dilation makes them larger and thicker. The SE's shape decides the direction: a vertical SE acts only vertically, a disk rounds corners.

Opening (A ⊖ B) ⊕ B removes small objects and thin bridges, keeps size. Closing (A ⊕ B) ⊖ B fills small holes and gaps, keeps size. Both are idempotent.

F22 A2(c)5 marks

What is a structuring element? What are the effects of erosion and dilation? Explain briefly with applications.

A structuring element is a small binary image (template) of any shape and size (square, cross, disk, line) with a defined origin. It is moved over the image like a filter mask, and at each position the fit or hit test between the SE and the image decides the output pixel.

Effects and applications of erosion and dilation: as in the answer above (erosion: shrink, remove noise, separate objects; dilation: grow, fill holes, bridge gaps, repair broken text).

Case studies (CLO3)

Recipe: name the operation, give its equation, say what it does to this exact problem, and why the alternative would fail.

the problem says…usewhy
small bright spots / specks on dark backgroundopeningerosion deletes specks smaller than B, dilation restores the real objects
small dark holes / pepper inside a white objectclosingdilation fills the holes, erosion restores the outline
broken characters, gaps in roads or linesdilation, or closing to keep the widththe SE bridges the gap
touching coins / cells to counterosion (repeated), then connected-component labelingerosion breaks the thin necks between objects
remove small particles, keep big onesopening with B larger than the small particlessmall ones cannot contain B and vanish
outline / boundary of objectsβ(A) = A − (A ⊖ B), or (A ⊕ B) − Adifference of the object and its eroded / dilated version
find corners, end points, a given shapehit-or-miss transform (deck 12)exact match of foreground and background pattern
SP25 Q3(c)3 + 3 + 3 + 1 marks

A satellite image of the AUST campus road network has noise (small bright spots), gaps in roads and overlapping structures. (i) Which morphological operation first removes the small bright spots, and why? (ii) After noise removal the roads are fragmented with small gaps: which operation connects them, and how? (iii) Develop the most suitable operation to highlight road boundaries. (iv) Can highlighting boundaries help distinguish roads from the background terrain?

(i) Opening, A ∘ B = (A ⊖ B) ⊕ B, with a small disk/square SE larger than the spots. The erosion deletes every bright spot that cannot contain B; the dilation then grows the roads back to their original width, so only the noise is removed. (Dilation first would enlarge the spots instead.)

(ii) Closing, A • B = (A ⊕ B) ⊖ B, with an SE a bit longer than the gaps (a line SE along the road direction works best). The dilation joins the road fragments across each gap; the erosion shrinks the roads back to their width, but the filled gaps stay filled, so the network becomes connected without fattening.

(iii) Boundary extraction β(A) = A − (A ⊖ B) with a 3×3 SE: erode the cleaned road image and subtract it from itself, leaving a one-pixel outline of every road. (Or (A ⊕ B) − A for the outer edge.)

(iv) Yes. The boundaries outline the road shapes sharply, separating them from the surrounding terrain; they can be used to segment, measure and map the road network.

F23 Q3(b)5 + 5 marks

(i) Automated coin counting: coins are circular blobs, but some touch. Which morphological operations separate touching coins for accurate counting, and why? (ii) A microscope image has small insignificant particles and larger ones: which operations remove the small ones but keep the large ones? Explain mathematically, with applications.

(i) Binarize the image, then apply erosion A ⊖ B = {z | (B)z ⊆ A} with a disk SE (repeated if needed). Touching coins are joined only by narrow necks; the disk cannot fit in a neck, so the necks disappear first and each coin becomes a separate, smaller blob. Then count the blobs with connected-component labeling (slides 43–44). Counting is not affected by the coins shrinking. (A dilation afterwards, i.e. an opening, would restore size, but could rejoin coins, so count after the erosion.)

(ii) Opening with an SE (disk) a little larger than the insignificant particles: A ∘ B = (A ⊖ B) ⊕ B. Erosion removes every particle that cannot contain B, i.e. all the small ones; the larger particles survive as shrunken cores, and the dilation grows them back to almost their original shape and size. Applications: cleaning cell or particle images before counting, removing dust in industrial inspection, removing noise in scanned documents.

SP24 Q3(a)ii4 marks

An image is corrupted by salt-and-pepper noise in the object part only. Which morphological operation would you use to remove it? Explain the process.

Inside a white object, the visible noise is the pepper: small black dots, i.e. tiny holes in the foreground. Use closing A • B = (A ⊕ B) ⊖ B with a small (3×3) SE: the dilation fills each black dot because the SE touches white on all sides; the erosion then restores the object's outline. Any white specks left outside the object could then be removed with an opening (open–close filtering). The background is untouched because it has no noise.

F22 A3(c)i · slide 434 marks

Coins image: which morphological operation can be used to count the coins? Explain the process.

Erosion followed by connected-component labeling: binarize; erode with a disk to separate the touching coins (and remove small noise); label the connected components; the number of labels = number of coins.

F21 B1(a) i–ii3 + 3 marks

(i) A text image has broken characters: which morphological operation joins them? (ii) Define opening and closing mathematically, with applications.

(i) Dilation with a small SE such as the 3×3 cross [0 1 0; 1 1 1; 0 1 0] (slide 59): any background pixel whose SE touches a character pixel becomes foreground, so the 1–2 pixel breaks are bridged and the characters become whole. A closing (dilation then erosion) joins the breaks the same way but returns the strokes to their original thickness.

(ii) Opening A ∘ B = (A ⊖ B) ⊕ B: removes small noise and thin bridges (cleaning scanned documents, separating objects). Closing A • B = (A ⊕ B) ⊖ B: fills small holes and gaps (repairing broken text, filling reflections in a thresholded object).

Traps and one-minute sheet

slides all
operationequationeffect
erosionA ⊖ B = {z | (B)z ⊆ A}shrink, remove small objects, split joins
dilationA ⊕ B = {z | (B̂)z ∩ A ≠ ∅}grow, fill holes, bridge gaps
openingA ∘ B = (A ⊖ B) ⊕ Bremove specks and thin bridges, keep size
closingA • B = (A ⊕ B) ⊖ Bfill holes and gaps, keep size
boundaryβ(A) = A − (A ⊖ B)inner outline
edge (outer)(A ⊕ B) − Aring outside the object
duality(A ⊖ B)c = Ac ⊕ B̂erosion via the background