0% found this document useful (0 votes)
62 views

Mathematical Morphology: Erosion Dilation Opening Closing

Mathematical morphology is a technique for image analysis and processing based on shapes. It involves four primary operations: erosion, dilation, opening, and closing. Erosion reduces objects in an image while dilation increases objects. Opening is used to remove unwanted structures like noise by performing an erosion followed by a dilation. Closing is used to merge or fill structures by performing a dilation followed by an erosion.

Uploaded by

Sanjay Bhatikar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Mathematical Morphology: Erosion Dilation Opening Closing

Mathematical morphology is a technique for image analysis and processing based on shapes. It involves four primary operations: erosion, dilation, opening, and closing. Erosion reduces objects in an image while dilation increases objects. Opening is used to remove unwanted structures like noise by performing an erosion followed by a dilation. Closing is used to merge or fill structures by performing a dilation followed by an erosion.

Uploaded by

Sanjay Bhatikar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Mathematical Morphology

• Erosion
• Dilation
• Opening
• Closing

1
Erosion

• Used to reduces objects in the image


• Definition, binary images:
– Does the structure element fit the set?
 B  X ={x∣B x ⊆X }
where Bx means B translated with x,
X is the image, and
B is the structure element

2
Erosion

• Example, binary image

3
Erosion

• Definition, grayscale images


We remember the definition for binary images:
 B  X ={x∣B x ⊆X }
Can be rewritten into the intersections of the translated sets X-b:

 B  X = ∩b∈B X −b
Which can be extended to also include grayscale images:

 B  f = ∧b∈B f −b

4
Erosion

• Based on
 B  f = ∧b∈B f −b
we can define an algorithm to find the erosion of image f:
[ B  f ] x=min b∈B f  xb

5
Erosion
• Example, grayscale image

f f+1

6 f-1 εΒ(f)
Erosion example

Erosion using
a SE matching
the inner
texture

7
Another erosion example

• Branches are important in a finger print comparison

SE used to identify branches

8
Original image
Another erosion example

Thresholded image Erosion result


9
Another erosion example

10
Identified finger print branches
Dilation

• Used to increase objects in the image


• Definition, binary images:
– Does the structure element hit the set?
 B  X ={x∣B x ∩X ≠∅}
where Bx means B translated with x,
X is the image, and
B is the structure element

11
Dilation

• Example, binary image

12
Dilation

• Definition, grayscale images


We remember the definition for binary images:
 B  X ={x∣B x ∩X ≠∅}
Can be rewritten into the unions of the translated sets X-b:

 B  X = ∪b∈ B X −b
Which can be extended to also include grayscale images:

 B  f = ∨b∈B f −b

13
Dilation

• Based on
 B  f = ∨b∈B f −b
we can define an algorithm to find the dilation of image f:
[dilation B  f ] x =max b∈B f  xb

14
Dilation
• Example, grayscale image

f f+1

15 f-1 δΒ(f)
Dilation

• Example 2, grayscale image

16
Dilation and erosion example

17
Beucher gradient

• Dilation and erosion can be used to extract edge information from


images
– Example: Beucher gradient
 B = B −B

18
Properties of dilation and erosion

• Dilation and erosion:


– are dual operators (C=complement):
B =C  B C
– are translation invariant operators
– do not change the ordering relations between two images
– are invariant with respect to threshold decomposition
– Do not necessarily keep the homotopy of an image
• There exist no inverse transform to restore the original image

19
Dilation and erosion composition

 B  B =
2 1 B 2 B1 

 B  B =
2 1 B 2
B1 

• For instance can a dilation with a 5x5 SE instead be computed using two
3x3 SEs:

20
Improving calculation efficiency using
parallel computing
• Dilation and erosion are algorithms that can be efficiently parallelised
• Solutions:
– Large multiprocessor computer
– Computer cluster
– Cellular neural network (implemented in hardware)
– The graphics processing units (GPU) on a modern graphics card
– More++?

21
GPU

• The GPU on modern graphics cards has evolved into an extremely


flexible and powerful processor
– Cheap
– Programmable
– Precise
– Fast
• 3 Ghz Pentium 4 theoretical: 6 GFLOPS
• GeForceFX 5900 observed: 20 GFLOPS
– Improving rapidly (faster than Moore's law)
• CPUs: annual growth ≈1.5x
• GPUs: annual growth > 2.0x

22 Courtesy of Kurt Akeley et al., GPU Gems


GPU Performance

23
Graphs courtesy of Ian Buck, Stanford University
GPU shortcomings

• Shortcomings
– No better than 32 bit floating point throughout the pipeline
– GPU programming currently requires GPU-specific knowledge
– Not all image processing tasks can be implemented on the GPU
– If branches are not efficient (can sometimes be replaced by more efficient
max or min operators)

24
GPU example uses

• Example previous uses in image processing


– Image filtering (for instance blurring, edge enhancement, noise removal)
– Level set solver
– Registration
– Motion estimation

Example image blurring,


25 courtesy of Robert Strzodka, IEEE Visualization 2004 Tutorial
GPU and mathematical morphology

• Both dilation and erosion can be implemented efficiently on the GPU


• Instead of using if branches, built-in max and min operators can be used
• Example Cg code for implementing dilation on the GPU:

float4 dilate(half2 coords : TEX0, uniform sampler2D image) : COLOR {


static const half offset = 1.0 / 256.0;

float4 p=tex2D(image, coords);


float4 p1=tex2D(image, coords+half2(offset, 0));
float4 p2=tex2D(image, coords+half2(-offset, 0));
float4 p3=tex2D(image, coords+half2(0, offset));
float4 p4=tex2D(image, coords+half2(0, -offset));

return max(p, max(p1, max(p2, max(p3, p4))));


}
26
GPU and mathematical morphology

• Problem: GPUs do not have 3D frame buffers (cannot handle 3D data


volumes throughout the pipeline)
• Solution: Flat 3D arrays

27
Images courtesy of Aaron Lefohn, University of California
Morphological opening

• Used to remove unwanted structures in the image (e.g. noise)


• Morphological opening is simply an erosion followed by a dilation:
 B  f = B [ B  f ]

• Binary example:

28
Morphological opening

• Grayscale example

29
Morphological closing

• Is used to merge or fill structures in an image


• Morphological closing is dilation followed by erosion:
 B  f = B [ B  f ]

• Binary example:

30
Another example

• How to segment the text from the uneven illumination in the image?

31
Another example

• How to segment the text from the uneven illumination in the image?

32
Another example

• How to segment the text from the uneven illumination in the image?

33
Properties of opening and closing

• Opening and closing are duel operators


• Closing is an extensive transform
• Opening is an anti-extensive transform
• Opening and closing keep the ordering relation between two images
• Opening and closing are idempotent transforms

34

You might also like