Download presentation
Presentation is loading. Please wait.
1
Morphological Operators
2
More on Homogeneous Intensity Regions
Morphology Refers to “form and structure” Defined as set operations Pixels that make up a region are the elements of the set Pixels not in the region are the elements outside the set Operate on binary images where connected components have been identified Basic implementation is similar to that of convolution with a kernel
3
(connected components with boundaries)
Pixels as Sets 1 3 2 5 4 1 Set of pixels (white) 5 Sets of pixels (connected components with boundaries)
4
Morphology Operations
Inputs Binary image (connected components) Structuring element (kernel) Output Processed regions Region Region Morphological Operation Structuring Element
5
Structuring Element Analogous to a convolution kernel
Acts as a “probe” of the binary image Designate an origin of the element May be the central pixel May be some other pixel Can be any shape or size
6
Structuring Element 1 1 1 1 1
7
Structuring Element Notice the empty spaces on the elements
These spaces are treated as “don’t cares” Clearly we must represent them as something when writing code You choose what the values should be and make sure you handle them consistently More on this later
8
Basic Operations Five common Morphological Operations Dilation Erosion
Closing Opening Hit And Miss
9
Dilation Used to enlarge a region
Sweep the structuring element over the image (as you did with convolution) Each time the origin lands on a pixel within the region… Write a 1 wherever the structuring element is a 1 That is, replicate the structuring element for every region pixel The effect will be to thicken lines, fill gaps and holes, and grow object boundaries
10
Dilation With a 3x3 structure element of all 1’s: INPUT OUTPUT
DIFFERENCE
11
Erosion Used to shrink a region
Sweep the structuring element over the image When all structuring elements (the 1’s) cover region pixels Place a 1 at the origin pixel of the output image The effect will be to thin lines and shrink object boundaries
12
Erosion With a 3x3 structure element of all 1’s: INPUT OUTPUT
DIFFERENCE
13
Closing Used to close internal holes and eliminate concavities from regions Concatenation of dilation/erosion operations Perform a dilation on the input image to produce an intermediate image Perform an erosion on the intermediate image to produce the output image
14
Closing With a 3x3 structure element of all 1’s: INPUT OUTPUT
DIFFERENCE
15
Opening Used to remove “tails” from regions
Concatenation of erosion/dilation operations Perform an erosion on the input image to produce an intermediate image Perform an dilation on the intermediate image to produce the output image
16
Opening With a 3x3 structure element of all 1’s: INPUT OUTPUT
DIFFERENCE
17
Another Example INPUT DILATE ERODE OPEN CLOSE
With a 3x3 structure element of all 1’s:
18
Hit And Miss Searches for specific patterns in the image
Sweep the structuring element over the image When all structuring elements match underlying image pixels exactly Consider structure element 1’s (region pixels), 0’s (non-region pixels), and “don’t cares” Logical OR the image pixel corresponding to the structure element origin into the output image (i.e. write a value to the output where the origin of the structuring element is)
19
Hit And Miss Note that the Structuring Element contains three types of values Foreground (region) indicators Background (non-region) indicators “don’t care” indicators Foreground indicators must land on region pixels Background indicators must land on non-region pixels Don’t care indicators can land on anything
20
Hit And Miss 1 STRUCTURING OUTPUT ELEMENT INPUT
There is a white pixel here (lower left corner of the square)
21
Compound Operations Advanced operations can be created by combining the basic operations Skeletonization (thinning) Thin(i, j) = I(i, j) ∩ HitAndMiss(I(i, j)) This will take a “wide” object and produce a thin object
22
From Edges to Lines The Hough Transform
23
From Edges To Lines Edges are a good start
They contain some important information and reduce the amount of raw data We don’t have to deal with all the pixel intensities that may not be all that informative But now we must do something with the edges As we saw last week, computing texture was one of the things we can do
24
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
25
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
26
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
27
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
28
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
29
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
30
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
31
Binarized edgels (edge pixels), not a line!
Hough Transform Hough Transform Binarized edgels (edge pixels), not a line!
32
Hough Transform What exactly is going on?
The Hough Transform is a technique for finding straight lines in a mass of disconnected points It’s a “model-based” technique It utilizes a mathematical equation (a model) of a line and then tries to fit points to the equation
33
Hough Transform Input image is [typically] a binarized edge magnitude map You could define it to use edge magnitudes in a manner similar to the Canny edge detector The process maps image space edge points to Hough Space coordinates The output image is the location of lines in image space What I showed was a rendering of Hough space which is not really the desired output
34
Hough Space A line in image space maps to a point in Hough Space
A point in image space maps to multiple points in Hough Space Each point (ρ, θ) in Hough space represents line in image space ρ is the perpendicular distance from the line to the origin θ is the orientation of the line relative to a specified axis
35
Hough Transform A single edge point in image space can be part of an infinite number of lines in image space Since “infinite” is a bit difficult to deal with in the digital computer world we quantize the orientation of the lines into convenient bins To compute the Hough Transform of a single point in image space we measure the distance from the origin to every possible line through the point
36
Hough Transform Specifically, we compute
for all values of θ. For example: θ ρ θ ρ Xp, Yp Xp, Yp
37
Hough Space The result is a sinusoidal waveform in Hough space
There is a single dot in here
38
Implementation Basic data structure is the accumulator matrix
θ ρ Similar to intensity histogram creation Initialize each location to 0 Set θ Calculate ρ Increment the (ρ, θ) bin
39
Mechanization When multiple dots contribute to the same line (are colinear) in image space the sin waves will intersect in a single point in Hough Space The coordinates of that point represent the parameters of the line
40
One Dot
41
Two Collinear Dots
42
Three Collinear Dots
43
Four Collinear Dots
44
Implementation Considerations
Must settle on an origin Upper left image corner Image center Lower left image corner Whatever Just choose one and document it Must select a quantization of the orientation Too fine of a quantization and the sinusoidal waves won’t intersect in a single point Too coarse of a quantization and near parallel lines are accumulated into a single bin
45
Implementation Considerations
The image points won’t always be perfectly collinear and therefore the Hough Space sinusoidal waves won’t always intersect in a single point Angle quantization Non-maximal peak suppression on the Hough accumulator array may be employed to reduce clustering effects (similar to the process used by Canny)
46
Implementation Considerations
The answer is in here somewhere
47
Implementation Considerations
After non-maximal peak suppression you may want to binarize (threshold) the accumulator array leaving only the strongest peaks Those represent locations where the most sinusoids intersected This is where the most number of points contributed to a given line (high degree of colinearity)
48
Implementation Considerations
The basic Hough Transform does not keep track of which points contribute to a line Make each accumulator bin a linked-list (or array) of image space point locations if you want to do this Edge orientation information is completely ignored May want to store this or use it to weight a particular edges contribution to the accumulator
49
“Gotchas” Make sure your accumulator array is initialized to 0 each time you compute a Hough Transform Make sure your accumulator array is big enough to hold all possible distances Distances can be as far as the diagonal length of the image Distances can be positive or negative dependent on how you choose your origin
50
Generalized Hough Transform
The only thing specific to a straight line is the parameterization – the process is general Basically, any shape that can be quantitatively described can be detected with the Hough Transform Many approaches to detecting circles have been published – especially fixed radius circles
51
Remainder of Class Period
Open for questions regarding current or past programming assignments Write code to perform Morphology operations: Erosion Dilation Open Close Hit and Miss
52
Things To Do Write code to perform Reading for Next week
The five basic morphological operations The Hough Transform Due 2 weeks from now Reading for Next week Chapter 6 – Color Why now? – because it is used to do segmentation, region description, and other mid-level vision stuff (as well as low-level operations) We’ll look at various color representations I especially like this topic
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.