Quiz: grey-level morphology
Before this unit: Opening, closing & the distance transform (previous unit); Day 12: Thresholding.
Short questions to test your understanding. Try each on paper first, then open the answer. With a flat SE B: erosion = min filter, dilation = max filter, opening I \circ B = erode then dilate, closing I \bullet B = dilate then erode; white top-hat I - I \circ B, black top-hat I \bullet B - I, gradient (I \oplus B) - (I \ominus B).
Q1. A fluorescence image has small bright spots (about 5 pixels across) on a background that gets brighter towards one side. Why does a single threshold fail, and which operation fixes it?
Compare the spot brightness on the dark side with the background brightness on the bright side.
A threshold low enough to catch the spots on the dark side is below the background on the bright side, and a threshold above the bright background misses the dim spots. A white top-hat with an SE larger than the spots (a disc of diameter 7–9) subtracts the opening, which follows the background but not the spots; on the top-hat the background is near 0 everywhere and one threshold works.
Q2. You open a 1D profile with a flat bar of width 9. A peak is 5 samples wide at its base. What is left of it? And of a plateau 12 samples wide?
Push the bar up from below.
The bar cannot enter the 5-sample peak at any height, so the peak is cut down to the level of its surroundings: it disappears. The 12-sample plateau is wider than the bar, so the bar reaches its top: the plateau is kept at full height (only its corners can be affected if its sides are sloped).
Q3. An image shows dark granules in a bright cytoplasm. Which top-hat do you use, and how do you choose the SE size?
Opening removes bright details, closing removes dark ones.
The black top-hat I \bullet B - I: the closing fills the dark granules (narrower than B) and follows everything else, so the difference is large exactly at the granules. B must be larger than the granules and smaller than the dark structures you want to ignore (and than the scale of brightness changes in the background).
Q4. What is the morphological gradient (window of 3) of the step 0\,0\,0\,0\,10\,10\,10\,10? How does it differ from a derivative filter such as Sobel?
Max minus min in each window of 3.
0\,0\,0\,10\,10\,0\,0\,0: the two samples next to the step see both levels. It has no sign (a rising and a falling step look the same) and no direction, it is as large as the full step (not the slope), and it never overshoots or rings. A derivative filter gives a signed value, proportional to the slope, with a direction (horizontal or vertical Sobel).
Q5. A signal has isolated bright and dark impulses (“salt and pepper”). Compare the min, the max and the median filter over a window of 3.
A single impulse in a window of 3 is either the smallest, the largest or the middle value?
The min filter removes the bright impulses but widens every dark impulse to 3 samples; the max does the opposite. The median takes the middle value: one impulse in a window of 3 is never the middle one, so both kinds disappear, and a step between two flat levels stays sharp. All three are rank filters of the same window.
Q6. Why does adding a constant brightness to the whole image not change its top-hat? Does multiplying by 2?
How do min and max behave under I \mapsto I + c and I \mapsto 2I?
\min(I + c) = \min I + c and \max(I + c) = \max I + c, so the opening shifts by c too and the difference is unchanged. Multiplying by 2 (a positive factor) also commutes with min and max, so the top-hat is multiplied by 2: the same details, twice as bright. A threshold on the top-hat must therefore scale with the image contrast, but not with an offset.
Q7. (math) Show that for a flat SE, \{x : (I \ominus B)(x) \ge t\} = \{x : I(x) \ge t\} \ominus B for every threshold t. What does it mean for “grey-level versus binary” morphology?
When is a minimum at least t?
\min_{b \in B} I(x + b) \ge t \iff I(x + b) \ge t for all b \in B \iff B_x \subseteq \{I \ge t\} \iff x \in \{I \ge t\} \ominus B. So grey-level erosion (and similarly dilation, opening, closing) with a flat SE is binary morphology applied to every level set of the image, and the results stack back into a grey image. It also means: thresholding and flat morphology can be done in either order.