Morphological Processing Heejune Ahn, SeoulTech Last updated 2015. May. 19

Preview:

Citation preview

Morphological Processing

Heejune Ahn, SeoulTech

Last updated 2015. May. 19

Outline Introduction

binary Image & terminology Operation

Structuring element Dilation & erosion Opening & Closing

Application Boundary Extraction Connected components Extraction Region Filling Skeletonization

1. Introduction Morphology

Concept

Morphological processing Extract ‘structural’ information image model = structure + texture(details) ‘simplification’ for easier understanding

Set-theory based

Set (image pixels) Set (structure)

C

operator

Set (image pixels)

morphology

structure

form linguistic

biology

2.Binary image binary image

Image with two values (1/0, true/false, on/off) foreground vs background pixel

foreground pixel: value = 1 background pixel: value = 0

Object and connected connected foreground pixels 4/8 connected

Binary against gray image No Texture info(variation of values) interested only in shape, size, location of object

3. Structuring elements Morphological operation

target pixel <= operation with neighbor pixels

Structuring elements size(odd/even), symmetric/not choice of S.E.

depends on application Main topics in M.P.

Set (image pixels) Set (structuring element)

C

operator

Set (image pixels)

4. Dilation & erosion Dilation & erosion

All other operation is defined by these two. Properties

Dilation Erosion

definition 1 if any neighbor = 10 o. w.

0 if any neighbor = 00 o. w.

visual BG pixels remain if the structure element is included

FG pixels remain if the structure element is included

effects expansion of the object shrink of the object

illustration

Fully connected FGs only SURIVE!

Fully connected BGs only SURIVE!

5. Dilation & Erosion in MATAB imerode(bw, se) & Imdilate(bw, se)

bw (b/w image), se (structuring element) Return result b/w image

structuring element defintion MATLAB array

E.g. se = [0 1 0; 1 1 1; 0 1 0 ] strel(‘shape’, ‘parameters’)

E.g. strel(‘square’, ‘4’) Special ‘strel’ object, not matlab array

6. SE decomposition SE decomposition

any operations = successive erosions & dilations Computational efficiency

Operation complexity ~ # of SE pixels E.g. 5-pixel square = 2 times of 3 pixels square

Computational gain = (5*5)/(2*(3*3)) = 25/18

In MATLAB ‘strel’ shows the information

E.g. se3 = strel(‘disk’, 5); ‘getsequence(se)’ returns set of decomposition

E.g. decomp = getsequence(se3); imerose/imdilate etc does it internally (w. strel obj)

7. Effects & uses of dilation & erosion Effects

Increase (dilation)/reduce (erosion) at boundary Caution

Not reversible process ( ). Why? careful choice of SE

Application to segmentation Breaks in edge boundary Dilation till closed contour Region filling Erode the boundary back

Another example

Tips: apply the same size (times) Same # of dilation and erosion

Particle Counting & sizing: do yourself.

Thresholding Horizontal-erosion

vertical-erosion Dilation * 2

8. Opening & closing Opening vs closing

Interpretation Erosion and dilation is ir-reversible. first operation is key, the next operation is to recover

the size Simplification of boundary

Illustration

9. Boundary extraction

Thickness of boundary With different structuring elements Ex8.7 & F8.11

In MATLAB bwperim(img): 1-pixel thick boundary extraction

10. Extracting connected compoents Labeling the connected objects

Background = 0, first obj = 1, and so on Algorithm-1

Scan from top-left to bottom-right if all neighbors = 0 or not labeled, assign a new

label p. If only one FG neighbor, assign p to the pixel If multiple FG neighbors, equivalent resolution

and assign smaller label.

Algorithm-2 Repeat until no more FG pixels Choose any unlabeled pixel

MATLAB [img, num] = Bwlabel(bimg) : labeling binary img Ex8.8 & F8.12

11. Region filling Holes (of background pixels)

often remains after segmentation process often needs to be filled.

Example

Hole

Object/Boundary

One object is filled All objects are filled

Algorithm First, file hole region

choose a hole X0 = {the hole} Find hole region

Then, fill/combine the hole region: In MATLAB

imfill(bwimg,’hole’), imfill(bwimg[,location, conn])

Restrict growing outside of boundary Extend the hole region

12. Hit-or-miss transform Detect a specific shape in a image (boundary)

Exactly the same pattern both in FG & BG. Algorithm

First, find hit in FG by erosion.

Second, miss in BG, by erosion Done by logical complement images.

Finally, combining two constraints/results

Hit-and-miss is better expression subsections not union!

Ex8.9 & F8.18

MATLAB imhitmiss(A, B1, B2) : exact & non-exact match

Generalized hit-or-miss Hit-or-miss

Detect only the exactly same shape

Generalization (relaxation) Practice needs ‘strict on FG but less strict in BG’

Less sensitive to noise and small variations.

13. Relaxing constraints forgiving structure in MATLAB(E8.10& F8.20)

imhitmiss(A, B1, B2)

imhitmiss(A, interval) Interval: 1 for FG, -1 for BG, 0 for “don’t care”

0 0 0

1 1 0

0 1 0

1 1 1

0 0 1

0 0 1

-1 -1 -1

1 1 -1

0 1 -1

Same as above more forgiving

0 -1 -1

0 1 -1

0 0 0

Thinning

If the foreground and background pixels in the structuring element exactly match foreground and background pixels in the image, then the image pixel underneath the origin of the structuring element is set to background (zero)

14. Skeletonization Skeleton

Reduce an object into bare-bone(minimal level)

Topological information Nodes, branches (length),

angles of branches Weakness

Sensitive to the small change/irregularity in morphology

E.g.) Not exact circle => not a point

Definition of skeleton Pixels of same distance from the boundary Prairie-fire analogy

Set a fire on the boundary and all fire spread at the same speed, then the skeleton is point where all fires met.

Implementation of skeleton By thinning until no more thinning is possible.

15. Opening by reconstruction Anisotropy effect (prob. in opening)

Opening remove the details of boundary Dilation changes the boundary similar to “SE.” Distortion when original shape too different from SE

Algorithm (reconstruct to original shape) M: mask = original image (shape) An : marker: eroded image (survived points) B : simple 3x3 SE Iterate Until

Ex. 8.12 mask = imread marker = imerode recon = imreconstruct

(marker, mask)

MASK (original)

Marker (Eroded, survived points ) Openning (reconstructed)

16-20. Grey-scale operation Extension of binary operations

Not covered in lecture 16. grey-scale erosion and dilation 17. grey-scale structuring elements: general 18. grey-scale erosion dilation with flat

structuring elements 19.Grey-scale opening and closing 20. top-hat transform

16&17. Gray scale erosion Extension of binary to gray-scale image

Erosion Min(A – B) over region B with center location

Dilation Max(A + B) over region B with center location

General structuring element Array of 0 or 1s (if structuring elements or not) Array of numbers (used for calculation)

Ex. Input image

Gray scale erosion

Gray scale dilation?

18. Flat structuring element Flat Structuring

Vb = zeros(), all elements = 0 Erosion with flat SE

Min filtering with window of SE Dilation with flat SE

Max filtering with windows of SE Morphological gradient

Dilation - Erosion Boundary?

19. Gray scale Opening & Closing Comparison

Ex 8.15: illumination compensation

Opening Closing

Binary Erase small objects Fill small holes

Gray scale Suppress small brightness parts

Suppress small darkness parts

Subtract illumination

Opening (15x15) Contrast extension

Recommended