Title: CIS303 Advanced Forensic Computing
1CIS303Advanced Forensic Computing
2Morphological Image Processing
- The word morphology denotes a branch of biology
that deals with the form and structure of animals
and plants. In image processing, the word is used
in the context of tools for extracting image
components that are useful e.g. by removing
imperfections such as those caused by noise,
texture or inaccurate specification of a
threshold. Morphological techniques can also be
applied to greyscale images, where they can be
used for non-linear smoothing and feature
enhancement. - Sub topics
- Erosion.
- Dilation.
- Opening and closing.
- Hit-and-Miss Transform.
- Thinning and thickening.
3Erosion
- Erosion shrinks or thins objects in a binary
image. - The manner and extent of shrinking is controlled
by a structuring element.
4Erosion
- Erosion is the set of all points in the image,
where the structuring element fits into. - Consider each foreground pixel in the input
image. If the structuring element fits in, write
a 1 at the origin of the structuring element. - Simple application of pattern matching.
- Erosion shrinks foreground and enlarges the
background
5Matlab function strel
- The IPT function strel constructs structuring
elements with a variety of shapes and sizes. Its
syntax is - se strel(shape, parameters)
- See Matlab help for the various syntax forms.
However, they include diamond, linear, disk,
octagon, rectangle, square, arbitrary etc. - Examples of an image eroded with a disk of radius
10, 5 and 20 are shown below
6Structuring element (kernel)
- Structuring Elements can have varying sizes.
- Usually, element values are 0,1 and none.
- Structural Elements have an origin.
- For thinning, other values are possible.
- Empty spots in the Structuring Elements are dont
cares.
71-D Erosion example (1)
Input image
Structuring Element
Output Image
81-D Erosion example (2)
91-D Erosion example (3)
101-D Erosion example (4)
111-D Erosion example (5)
121-D Erosion example (6)
131-D Erosion example (7)
141-D Erosion example (8)
15Counting coins example
- Counting objects can be difficult when they touch
each other. - Solution Binarization and Erosion separates
them. - Note that the coins become smaller can be a
problem if structuring element causes object to
disappear!
In Matlab, use the strel function to construct
the structuring element, in conjunction with
imerode to perform the erosion process.
16Dilation
- Dilation has the opposite effect of erosion.
- It grows or thickens objects in a binary
image. - As in erosion, this is controlled by the
structuring element.
17Exercise
In the 1-D example below, deduce the final image
following dilation.
Input image
Structuring Element
Output Image
Solution
18Dilation examples
Edge Detection (a) Dilate input image (b)
Subtract input image from dilated image (c)
Edges remain.
19Opening and Closing
- Derived from the fundamental operations of
Dilatation and Erosion. - Usually applied to binary images, but gray value
images are also possible. - Opening and closing are dual operations.
- Opening and Closing are idempotent repeated
application has no further effects. - Opening
- Similar to Erosion.
- Used mainly for spot and noise removal.
- However, it is less destructive than erosion.
- Opening is defined as an Erosion, followed by a
Dilatation using the same structuring element for
both operations.
20Opening
- Take the structuring element (SE) and slide it
around inside each foreground region. - All pixels which can be covered by the SE with
the SE being entirely within the foreground
region will be preserved. - All foreground pixels which can not be reached by
the structuring element without lapping over the
edge of the foreground object will be eroded
away! - Example Structuring element 3x3 square
21Opening examples
Opening with a 11 pixel diameter disc
3x9 and 9x3 Structuring Element
22Closing
- Closing
- Similar to Dilation used for removal of holes.
- Tends to enlarge regions and shrink backgrounds.
- Closing is defined as a Dilatation, followed by
an Erosion using the same structuring element for
both operations. - Take the structuring element (SE) and slide it
around outside each foreground region. - All background pixels which can be covered by the
SE with the SE being entirely within the
background region will be preserved. - All background pixels which can not be reached by
the structuring element without lapping over the
edge of the foreground object will be turned into
a foreground.
23Closing example
Example structuring element 3x3 square
24Another closing example
Closing operation with a 22 pixel disc, closes
small holes in the foreground.
25And another
Threshold, closing with disc of size 20.
Note that opening is the dual of closing i.e.
opening the foreground pixels with a particular
structuring element is equivalent to closing the
background pixels with the same element.
26DIPUM illustration of opening and closing
27Opening followed by closing example (DIPUM)
- Opening removes the noisy spots in the
fingerprint image. However, numerous gaps are
introduced in the ridges of the fingerprint. - These are filled in by the closing operation
- See imopen and imclose in Matlab.
28Top-hat transformation (grayscale morphology)
- Openings can be used to compensate for
non-uniform background illumination. - Uneven illumination can make thresholding
difficult. - Opening a grayscale image can produce a
reasonable estimate of the background to the
image, provided the structuring element is large
enough so that it doesnt fit entirely within the
objects. - By subtracting this background image from the
original, we can produce an image of the objects
with a reasonable even background. - This is called a top-hat transformation and can
be done in Matlab using the following IPT
function - f2 imtophat(f, se)
- This is illustrated by the example on the
following slide.
29Top-hat transformation DIPUM example
30Hit-and-miss transform
- Used to look for particular patterns of
foreground and background pixels - Very simple object recognition
- Example for a Hit-and-miss Structuring Element
Contains 0s, 1s and dont cares. Usually a 1
at the origin
- Similar to Pattern Matching
- If foreground and background pixels in the
structuring element exactly match foreground and
background pixels in the image, then the pixel
underneath the origin of the structuring element
is set to the foreground colour.
31Hit-and-miss example corner detection
- Structuring Elements representing four corners.
- Apply each Structuring Element.
- Use OR operation to combine the four results.
32Thinning
- Used to remove selected foreground pixels from
binary images - After edge detection, lines are often thicker
than one pixel. Thinning can be used to thin
those line to one pixel width. - Definition let K be a kernel and I be an image
- Thin(I,K) I HitAndMiss(I,K)
- with 0-10
- If foreground and background fit the structuring
element exactly, then the pixel at the origin of
the SE is set to 0! - Note that the value of the SE at the origin is 1
or dont care!
33Thinning example
34Thickening
- Used to grow selected regions of foreground
pixels e.g. applications like approximation of
convex hull. - Definition let K be a kernel and I be an image
- Thicken(I,K) I HitAndMiss(I,K)
- with 111
35Labelling connected components - definitions
36Labelling connected components - bwlabel
- The IPT function bwlabel computes all the
connected components in a binary image - L num bwlabel(f, conn)
- Where f is a binary image and conn specifies the
desired connectivity (default 8). - Output L contains the labelled matrix. The pixels
in each different connected component are
assigned a unique integer, from 1 to the total
number of connected components. - In other words, the pixels labelled 1 belong to
the first connected component, those labelled 2
belong to the second etc. - Regional descriptors for the objects can then be
computed using the Matlab function regionprops.
(e.g. Area, perimeter etc.)
37Example (DIPUM)
38Tutorial
- In this weeks laboratory, investigate the
following - Create M-files to demonstrate the Matlab code
given on these slides. - Investigate the following Matlab commands (use
the Matlab Help information) strel imerode
imdilate imopen imclose. - Investigate bwhitmiss and bwmorph in Matlab.
Using suitable images, try out various operations
including thickening and thinning. - Try out the following web sites
- http//www.s2.chalmers.se/research/image/Java/appl
ets_list.htm - http//homepages.inf.ed.ac.uk/rbf/HIPR2/fulldemo.h
tm