1 what is image segmentation? there are many definitions. three common ones are image segmentation...
TRANSCRIPT
11
What is Image Segmentation
There are many definitions Three common There are many definitions Three common
ones areones are
Image Segmentation is the process of Image Segmentation is the process of
isolating objects of interest from the rest isolating objects of interest from the rest
of the scene (of the scene (Castleman Castleman ))
Image segmentation is the process of Image segmentation is the process of
partitioning partitioning (( 分 割分 割 ) ) an image into non-an image into non-
intersecting region such that each region intersecting region such that each region
is homogeneous is homogeneous (( 相似的相似的 ) ) and the union of and the union of
no two adjacent regions is homogeneous no two adjacent regions is homogeneous
((Pal Pal ))
22
What is Image Segmentation
Image segmentation is to divide an image Image segmentation is to divide an image
into parts that have a strong correlation into parts that have a strong correlation
with objects or areas of the real world with objects or areas of the real world
contained in the image (contained in the image (Watt Watt ))
In brief sIn brief segmentation is to subdivide an egmentation is to subdivide an
imageimage into its constituentinto its constituent ( ( 组成的组成的 )) regions regions
or objectsor objects
―Segmentation should stop when theSegmentation should stop when the
objects of interest in an application objects of interest in an application
havehave been isolatedbeen isolated
33
Image Processing Flow based onImage Processing Flow based on
Image SegmentationImage Segmentation
Image Segmentation
InputInputImageImage
ObjectObjectImageImage
FeatureFeatureVectorVector
ObjectObjectTypeType
FeatureExtraction
Classification
44
Why is it difficult
In generalIn general autonomousautonomous ( ( 自 主 的自 主 的 ))
segmentation is one segmentation is one of of the most difficult the most difficult
tasks in image processing It tasks in image processing It isis difficult difficult
because of because of many reasonmany reasonss Here are some Here are some
typical obstaclestypical obstacles Non-uniform illuminationNon-uniform illumination
No control of the environmentNo control of the environment
Inadequate model of the object of interestInadequate model of the object of interest
NoiseNoise
etcetc
55
Segmentation methods can be divided into three groups according to the dominant features they employ
Segmentation based on global knowledge about an image
―The knowledge is usually represented by a histogram of image features
Edge-based segmentations
―Utilizing edge detection processes to find a closed boundary so that an inside and an outside can be defined
Region-based segmentations
―This techniques proceed by dividing the image into regions that exhibit similar properties
Principal approachesPrincipal approaches
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
22
What is Image Segmentation
Image segmentation is to divide an image Image segmentation is to divide an image
into parts that have a strong correlation into parts that have a strong correlation
with objects or areas of the real world with objects or areas of the real world
contained in the image (contained in the image (Watt Watt ))
In brief sIn brief segmentation is to subdivide an egmentation is to subdivide an
imageimage into its constituentinto its constituent ( ( 组成的组成的 )) regions regions
or objectsor objects
―Segmentation should stop when theSegmentation should stop when the
objects of interest in an application objects of interest in an application
havehave been isolatedbeen isolated
33
Image Processing Flow based onImage Processing Flow based on
Image SegmentationImage Segmentation
Image Segmentation
InputInputImageImage
ObjectObjectImageImage
FeatureFeatureVectorVector
ObjectObjectTypeType
FeatureExtraction
Classification
44
Why is it difficult
In generalIn general autonomousautonomous ( ( 自 主 的自 主 的 ))
segmentation is one segmentation is one of of the most difficult the most difficult
tasks in image processing It tasks in image processing It isis difficult difficult
because of because of many reasonmany reasonss Here are some Here are some
typical obstaclestypical obstacles Non-uniform illuminationNon-uniform illumination
No control of the environmentNo control of the environment
Inadequate model of the object of interestInadequate model of the object of interest
NoiseNoise
etcetc
55
Segmentation methods can be divided into three groups according to the dominant features they employ
Segmentation based on global knowledge about an image
―The knowledge is usually represented by a histogram of image features
Edge-based segmentations
―Utilizing edge detection processes to find a closed boundary so that an inside and an outside can be defined
Region-based segmentations
―This techniques proceed by dividing the image into regions that exhibit similar properties
Principal approachesPrincipal approaches
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
33
Image Processing Flow based onImage Processing Flow based on
Image SegmentationImage Segmentation
Image Segmentation
InputInputImageImage
ObjectObjectImageImage
FeatureFeatureVectorVector
ObjectObjectTypeType
FeatureExtraction
Classification
44
Why is it difficult
In generalIn general autonomousautonomous ( ( 自 主 的自 主 的 ))
segmentation is one segmentation is one of of the most difficult the most difficult
tasks in image processing It tasks in image processing It isis difficult difficult
because of because of many reasonmany reasonss Here are some Here are some
typical obstaclestypical obstacles Non-uniform illuminationNon-uniform illumination
No control of the environmentNo control of the environment
Inadequate model of the object of interestInadequate model of the object of interest
NoiseNoise
etcetc
55
Segmentation methods can be divided into three groups according to the dominant features they employ
Segmentation based on global knowledge about an image
―The knowledge is usually represented by a histogram of image features
Edge-based segmentations
―Utilizing edge detection processes to find a closed boundary so that an inside and an outside can be defined
Region-based segmentations
―This techniques proceed by dividing the image into regions that exhibit similar properties
Principal approachesPrincipal approaches
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
44
Why is it difficult
In generalIn general autonomousautonomous ( ( 自 主 的自 主 的 ))
segmentation is one segmentation is one of of the most difficult the most difficult
tasks in image processing It tasks in image processing It isis difficult difficult
because of because of many reasonmany reasonss Here are some Here are some
typical obstaclestypical obstacles Non-uniform illuminationNon-uniform illumination
No control of the environmentNo control of the environment
Inadequate model of the object of interestInadequate model of the object of interest
NoiseNoise
etcetc
55
Segmentation methods can be divided into three groups according to the dominant features they employ
Segmentation based on global knowledge about an image
―The knowledge is usually represented by a histogram of image features
Edge-based segmentations
―Utilizing edge detection processes to find a closed boundary so that an inside and an outside can be defined
Region-based segmentations
―This techniques proceed by dividing the image into regions that exhibit similar properties
Principal approachesPrincipal approaches
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
55
Segmentation methods can be divided into three groups according to the dominant features they employ
Segmentation based on global knowledge about an image
―The knowledge is usually represented by a histogram of image features
Edge-based segmentations
―Utilizing edge detection processes to find a closed boundary so that an inside and an outside can be defined
Region-based segmentations
―This techniques proceed by dividing the image into regions that exhibit similar properties
Principal approachesPrincipal approaches
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
66
2 basis properties of intensity 2 basis properties of intensity valuesvalues
Segmentation algorithms generally are baseSegmentation algorithms generally are based on one of 2 basis properties of intensity vad on one of 2 basis properties of intensity valueslues DiscontinuityDiscontinuity
―to partition an image based on abrupt (to partition an image based on abrupt ( 突然突然的的 ) changes in intensity (such as edges)) changes in intensity (such as edges)
SimilaritySimilarity
―to partition an image into regions that are simto partition an image into regions that are similar according to a set of predefined criteriailar according to a set of predefined criteria
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
77
Detection of DiscontinuitiesDetection of Discontinuities
detect the three basic types of gray detect the three basic types of gray
level discontinuitieslevel discontinuities
points lines edgespoints lines edges
the common way is to run a mask the common way is to run a mask
through the imagethrough the image
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
88
ContentsContents
ThresholdingThresholding
Point DetectionPoint Detection
Line DetectionLine Detection
Edge-based SegmentationEdge-based Segmentation
Region-based SegmentationRegion-based Segmentation
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
99
71 Thresholding71 Thresholding
Thresholding is a labeling operation Thresholding is a labeling operation
on a gray scale image that on a gray scale image that
distinguishes pixels of a higher distinguishes pixels of a higher
intensity from pixels with a lower intensity from pixels with a lower
intensity valueintensity value
The output of thresholding usuallyThe output of thresholding usually is is a a
binary imagebinary image
This technique is particularly useful This technique is particularly useful
for scenes which contain for scenes which contain solid objects solid objects
on a uniform contrasting backgroundon a uniform contrasting background
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1010
Classification of ThresholdingClassification of Thresholding
Thresholding can be viewed as an operation Thresholding can be viewed as an operation that involves tests against a function T of ththat involves tests against a function T of the forme form
where p(xy) denotes some local property of this where p(xy) denotes some local property of this pointpoint
T T x y p x y f x y
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1111
Classification of ThresholdingClassification of Thresholding
When T depends onWhen T depends on only f(xy) only on gray-level valuesonly f(xy) only on gray-level values
1048638 1048638 Global Global thresholdingthresholding
both f(xy) and p(xy) on gray-level values and itboth f(xy) and p(xy) on gray-level values and its neighborss neighbors
Local Local thresholdingthresholding
x and y (in addition)x and y (in addition)
Dynamic Dynamic thresholdingthresholding
T T x y p x y f x y
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1212
Basic Global ThresholdingBasic Global Thresholding
Original imageOriginal image HistogramHistogram
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
SolutionSolution use T midway between the max and use T midway between the max and
min gray levelsmin gray levels
See ldquobasic_global_threSee ldquobasic_global_thremrdquomrdquo
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1313
Basic Global ThresholdingBasic Global Thresholding
Let light objects in dark backgroundLet light objects in dark background
To extract the objectsTo extract the objects Select a ldquoTrdquo that separates the objects from thSelect a ldquoTrdquo that separates the objects from th
e backgrounde background
ie any (xy) for which f(xy)gtT is an object point ie any (xy) for which f(xy)gtT is an object point
A thresholded imageA thresholded image
1
0
if f x y T backgroundg x y
if f x y T foreground
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1414
Heuristic Global ThresholdingHeuristic Global Thresholding
11 Select an initial estimate for TSelect an initial estimate for T
22 Segment the image using T This will produce two Segment the image using T This will produce two groups of pixels Ggroups of pixels G11 consisting of all pixels with gra consisting of all pixels with gray level values lt T and Gy level values lt T and G22 consisting of pixels with g consisting of pixels with gray level values ray level values T T
33 Compute the average gray level values μCompute the average gray level values μ11 and μ and μ22 fo for the pixels in regions Gr the pixels in regions G11 and G and G22
44 Compute a new threshold value T=05(μCompute a new threshold value T=05(μ11+μ+μ22))
55 Repeat steps 2 through 4 until the difference in T iRepeat steps 2 through 4 until the difference in T in successive iterations is smaller than a predefinen successive iterations is smaller than a predefined parameter Td parameter T00 seerdquohhellipmrdquo seerdquohhellipmrdquo
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1515
Basic Adaptive ThresholdingBasic Adaptive Thresholding
subdivide original image into small areassubdivide original image into small areas
utilize a different threshold to segment each utilize a different threshold to segment each subimagessubimages
since the threshold used for each pixel depesince the threshold used for each pixel depends on the location of the pixel in terms of tnds on the location of the pixel in terms of the subimages this type of thresholding is ahe subimages this type of thresholding is adaptivedaptive
See ldquoAdaptive_thresholdmrdquoSee ldquoAdaptive_thresholdmrdquo
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1616
Multilevel ThresholdingMultilevel Thresholding
a point (xy) belongs toa point (xy) belongs to an object class if Tan object class if T11 ltlt f(xy) le T f(xy) le T22
another object class if f(xy) another object class if f(xy) gtgt T T22
to background if f(xy) le Tto background if f(xy) le T11
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1717
The histogram of an image containing two pThe histogram of an image containing two principal brightness regions can be considererincipal brightness regions can be considered an estimate of the brightness probability d an estimate of the brightness probability density function p(z)density function p(z) p(z) is the sum (or mixture) of two unimodal (p(z) is the sum (or mixture) of two unimodal ( 单单峰的峰的 ) densities (one for light one for dark region) densities (one for light one for dark regions)s)
1 1 2 2
1 2 1
p z P p z P p z
P P
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1818
Optimal ThresholdingOptimal Thresholding
If the form of the If the form of the
densities is densities is
known or known or
assumed in assumed in
terms of terms of
minimum error minimum error
determining an determining an
optimal optimal
threshold for threshold for
segmenting the segmenting the
image is image is
possiblepossible
1 1 2 2
1 2 1
p z P p z P p z
P P
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
1919
Optimal ThresholdingOptimal Thresholding
Probability of erroneouslyProbability of erroneously
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2020
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error Differentiating ( Differentiating ( 微分微分 ) E(T) with respect to T (usi) E(T) with respect to T (usi
ng Leibnizrsquos rule) and equating the result to 0ng Leibnizrsquos rule) and equating the result to 0
find T which makesfind T which makes
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2121
Optimal ThresholdingOptimal Thresholding
Minimum errorMinimum error
Specially if Specially if PP11 = P = P22 then the optimum then the optimum
threshold is where the curve pthreshold is where the curve p11(z) and (z) and
pp22(z) intersect(z) intersect
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2222
Optimal ThresholdingOptimal Thresholding
For exampleFor example
Let Let PDF=Gaussian densityPDF=Gaussian density p p11(z) and (z) and
pp22(z)(z)
where μwhere μ11 and σ and σ1122 are the mean and are the mean and
variance of the Gaussian density of one variance of the Gaussian density of one
objectobject
μμ22 and σ and σ2222 are the mean and variance of are the mean and variance of
the Gaussian density of the other objectthe Gaussian density of the other object
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2323
Optimal ThresholdingOptimal Thresholding
Quadratic equation (Quadratic equation (二次方程二次方程 ))
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2424
Problems of ThresholdingProblems of Thresholding
Original imageOriginal image Thresholded imageThresholded image
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2525
Problems of ThresholdingProblems of Thresholding
(a)(a) Exact threshold Exact threshold
segmentationsegmentation
(b)(b) Threshold too lowThreshold too low
(c)(c) Threshold too Threshold too
highhigh
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2626
72 Point Detection72 Point Detection
a point has been detected at the a point has been detected at the
location on which the mark is location on which the mark is
centered ifcentered if
|R|geT|R|geT
where T is a nonnegative thresholdwhere T is a nonnegative threshold
R is the sum of products of the R is the sum of products of the
coefficients with the gray levels contained coefficients with the gray levels contained
in the region encompassed by the markin the region encompassed by the mark
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2727
72 Point Detection72 Point Detection
Note that the mark is the same as the mask Note that the mark is the same as the mask of Laplacian Operation (in chapter 3)of Laplacian Operation (in chapter 3)
The only differences that are considered intThe only differences that are considered interest are those large enough (as determined erest are those large enough (as determined by T) to be considered isolated pointsby T) to be considered isolated points
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2828
ExampleExample
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
2929
73 Line Detection73 Line Detection
Horizontal mask will result with max Horizontal mask will result with max
response when a line passed through the response when a line passed through the
middle row of the mask with a constant middle row of the mask with a constant
backgroundbackground
the similar idea is used with other masksthe similar idea is used with other masks
Note the preferred direction of each mask Note the preferred direction of each mask
is weighted with a larger coefficient (ie2) is weighted with a larger coefficient (ie2)
than other possible directionsthan other possible directions
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
1 1 1 1 1 2 1 2 1 2 1 1
2 2 2 1 2 1 1 2 1 1 2 1
1 1 1 2 1 1 1 2 1 1 1 2
45 45Horizontal Vertical
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3030
Idea 1 of Line DetectionIdea 1 of Line Detection
Apply every masks on the imageApply every masks on the image let R1 R2 R3 R4 denotes the response of the horlet R1 R2 R3 R4 denotes the response of the hor
izontal +45 degree vertical and -45 degree maskizontal +45 degree vertical and -45 degree masks respectivelys respectively
if at a certain point in the imageif at a certain point in the image
|Ri||Ri|gtgt|Rj||Rj|
for all jnei that point is said to be more likelfor all jnei that point is said to be more likely associated with a line in the direction of my associated with a line in the direction of mask iask i
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3131
Idea 2 of Line DetectionIdea 2 of Line Detection
Alternatively if we are interested in detectiAlternatively if we are interested in detecting all lines in an image in the direction definng all lines in an image in the direction defined by a given mask we simply run the mask ed by a given mask we simply run the mask through the image and threshold the absoluthrough the image and threshold the absolute value of the resultte value of the result
After thresholding the points that are left aAfter thresholding the points that are left are the strongest responses which for lines re the strongest responses which for lines one pixel thick correspond closest to the dione pixel thick correspond closest to the direction defined by the maskrection defined by the mask
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3232
ExampleExample
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3333
74 Edge-based 74 Edge-based SegmentationSegmentation
Edge-based segmentations rely on edges found in an image by edge detecting operators
these edges mark image locations of discontinuities in gray level
Edge detection is the most common approach for detecting meaningful discontinuities in gray level
There are a large group of methods based on information about edges in the image
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3434
What is edgeWhat is edge
Edge is where change occurs Change is measured by derivative in 1D
―Biggest change derivative has maximum magnitude
Or 2nd derivative is zero we discuss approaches for implementing
―first-order derivative (Gradient operator)
―second-order derivative (Laplacian operator)
―we have introduced both derivatives in chapter 3
―Here we will talk only about their properties for edge detection
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3535
What is edgeWhat is edge
In other wordsIn other words an edge is a set of an edge is a set of
connected pixelsconnected pixels
that lie on the boundary between two that lie on the boundary between two
regions with relatively distinct gray-level regions with relatively distinct gray-level
propertiesproperties
Note edge vs boundaryNote edge vs boundary
―an edge is a ldquolocalrdquo conceptan edge is a ldquolocalrdquo concept
―whereas a region boundary owing to whereas a region boundary owing to
the way it is defined is a more global the way it is defined is a more global
ideaidea
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3636
Ideal and Ramp (Ideal and Ramp (斜坡斜坡 ) Edges) Edges
because of because of
optics optics
sampling sampling
image image
acquisition acquisition
imperfectionimperfection
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3737
Thick and Thin EdgeThick and Thin Edge
The slope of the ramp is inversely The slope of the ramp is inversely
proportional to the degree of blurring in the proportional to the degree of blurring in the
edgeedge
Namely we no longer have Namely we no longer have a thin (one pixel thick) a thin (one pixel thick)
pathpath
Instead an edge point now is any point Instead an edge point now is any point
contained in the ramp and contained in the ramp and an edge would an edge would
then be a set of such points that are then be a set of such points that are
connectedconnected
The thickness is determined by the length of the The thickness is determined by the length of the
rampramp
The length is determined by the slope which is in The length is determined by the slope which is in
turn determined by the degree of blurringturn determined by the degree of blurring
Blurred edges tend to be thick and sharp Blurred edges tend to be thick and sharp
edges tend to be thinedges tend to be thin
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3838
First and Second derivatives (First and Second derivatives ( 导数导数 ))
the signs of the the signs of the
derivatives would be derivatives would be
reversed for an edge reversed for an edge
that transitions from that transitions from
light to darklight to dark
First First derivatderivatee
SeconSecond d derivatderivatee
Gray-Gray-level level profileprofile
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
3939
Second derivativesSecond derivatives
an undesirable featurean undesirable feature
produces 2 values for every edge in an produces 2 values for every edge in an
imageimage
zero-crossing propertyzero-crossing property
an imaginary straight line joining the an imaginary straight line joining the
extreme positive and negative values of extreme positive and negative values of
the second derivative would cross zero the second derivative would cross zero
near the midpoint of the edgenear the midpoint of the edge
quite useful for locating the centers of quite useful for locating the centers of
thick edgesthick edges
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4040
Basic idea of edge detectionBasic idea of edge detection
A profile is defined perpendicularly to A profile is defined perpendicularly to
the edge direction and the results are the edge direction and the results are
interpretedinterpreted
The magnitude of the first derivative is The magnitude of the first derivative is
used to detect an edge (if a point is on a used to detect an edge (if a point is on a
ramp)ramp)
The sign of the second derivative can The sign of the second derivative can
determine whether an edge pixel is on the determine whether an edge pixel is on the
dark or light side of an edgedark or light side of an edge
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4141
Review of First DerivateReview of First Derivate
Gradient OperatorGradient Operator simplest approximation 2simplest approximation 222
Roberts cross-gradientoperators 2Roberts cross-gradientoperators 222
Sobel operators 3Sobel operators 333
6 5 8 5x yG z z G z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
1 2 3
4 5 6
7 8 9
z z z
z z z
z z z
9 5 8 6x yG z z G z z 1 0 0 1
0 1 1 0
1 0 0 1
0 1 1 0
7 8 9 1 2 3
3 6 9 1 4 7
2 2
2 2
x
y
G z z z z z z
G z z z z z z
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
x yf G G
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4242
Edge direction and strengthEdge direction and strength
Let α(xy) represents the direction angle of tLet α(xy) represents the direction angle of the vector f at (xy)he vector f at (xy)
α(xy)=tanα(xy)=tan-1-1(GyGx)(GyGx)
The direction of an edge at (xy) perpendiculThe direction of an edge at (xy) perpendicular (ar ( 垂直垂直 ) to the direction of the gradient vec) to the direction of the gradient vector at that pointtor at that point
The edge strength is given by the gradient mThe edge strength is given by the gradient magnitudeagnitude
2 2x yf G G
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4343
Gradient MasksGradient Masks
1 0 0 1
0 1 1 0
Roberts
1 0 0 1
0 1 1 0
Roberts
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 2 1 1 0 1
0 0 0 2 0 2
1 2 1 1 0 1
Sobel
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
1 1 1 1 0 1
0 0 0 1 0 1
1 1 1 1 0 1
Prewitt
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4444
Diagonal edges with PrewittDiagonal edges with Prewittand Sobel masksand Sobel masks
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
0 1 1 1 1 0
1 0 1 1 0 1
1 1 0 0 1 1
Prewitt
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4545
Review of Second DerivateReview of Second Derivate
Laplacian OperatorLaplacian Operator
21 1
1 1 4
f x y f x yf
f x y f x y f x y
0 1 0
1 4 1
0 1 0
0 1 0
1 4 1
0 1 0
LaplacianLaplacian
MaskMask
1 1 1
1 8 1
1 1 1
1 1 1
1 8 1
1 1 1
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4646
Example of edge detectionExample of edge detection
See Matlab Help--demo--toolbox--image proSee Matlab Help--demo--toolbox--image processing--analysishellip--Edge detectioncessing--analysishellip--Edge detection
Note The Laplacian is seldom used in practiNote The Laplacian is seldom used in practice becausece because unacceptably sensitive to noise (as second-order unacceptably sensitive to noise (as second-order
derivative)derivative)
produces double edgesproduces double edges
unable to detect edge directionunable to detect edge direction
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4747
Canny edge detectorCanny edge detector
The most powerful edge-detection The most powerful edge-detection
method method
It differs from the other edge-It differs from the other edge-
detection methods in that detection methods in that
it uses two different thresholds (to detect it uses two different thresholds (to detect
strong and weak edges) strong and weak edges)
and includes the weak edges in the and includes the weak edges in the
output only if they are connected to output only if they are connected to
strong edges strong edges
This method is therefore less likely This method is therefore less likely
than the others to be fooled by than the others to be fooled by
noise and more likely to detect true noise and more likely to detect true
weak edgesweak edges
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4848
Laplacian of GaussianLaplacian of Gaussian
Laplacian combined with smoothing to find Laplacian combined with smoothing to find edges via zero-crossingedges via zero-crossing
2 2 22
4 2
2 2 2
2exp
r rh
r x y
determines the degrdetermines the degree of blurring that occee of blurring that occursurs
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
4949
Laplacian of Gaussian (Laplacian of Gaussian (Mexican hatMexican hat))
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
0 0 1 0 0
0 1 2 1 0
1 2 16 2 1
0 1 2 1 0
0 0 1 0 0
The coefficient must sum to The coefficient must sum to
zerozero
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5050
Edge Detection and Edge Detection and SegmentationSegmentation
Image resulting from edge detection cannot be used as a segmentation result
Supplementary processing steps must follow to combine edges into edge chains that correspond better with borders (boundary) in the image
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5151
75 Region-based 75 Region-based SegmentationSegmentation
GoalGoal find regions that are ldquohomogeneou find regions that are ldquohomogeneousrdquo by some criterionsrdquo by some criterion
Segmentation is a process that partitions Segmentation is a process that partitions R R iinto n subregions nto n subregions RR11 RR22 hellip hellip RRnn such thatsuch that
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
PP((RRii) is a logical predicate ) is a logical predicate property defined over the property defined over the points in set points in set RRii
For example For example PP((RRii) = TRUE i) = TRUE if all pixel in f all pixel in RRii have the sa have the same gray levelme gray level
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5252
Two methods of Region Two methods of Region SegmentationSegmentation
Region GrowingRegion Growing
Region SplittingRegion Splitting
Region growing is the opposite of the Region growing is the opposite of the
split and merge approachsplit and merge approach
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5353
Region GrowingRegion Growing
The objective of segmentation is to The objective of segmentation is to
partition an image into regionspartition an image into regions
A region is a connected component with A region is a connected component with
some uniformity (say gray-levels or some uniformity (say gray-levels or
texture)texture)
In region growing we start with a set In region growing we start with a set
of of ldquoseedrdquoldquoseedrdquo points growing by points growing by
appending to each seedrsquos neighbor appending to each seedrsquos neighbor
pixels if they have pixels if they have similar propertiessimilar properties
such as specific ranges of gray level such as specific ranges of gray level
and and lsquo8-connected neighborrsquolsquo8-connected neighborrsquo
Need initialization Need initialization similarity similarity
criterioncriterion
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5454
Steps of Region GrowingSteps of Region Growing
Start by choosing an arbitrary seed Start by choosing an arbitrary seed
pixel andpixel and compare it with neighbor compare it with neighbor
ppixelsixels
When When seedseed and and neighbor neighbor ppixelsixels are are similarsimilar and 8-connected neighbor r and 8-connected neighbor region egion
is grown from the seed pixel by is grown from the seed pixel by
addingadding neighboneighborr pixel pixelss
When the growth of one region stopsWhen the growth of one region stops
choose another seed pixel which doeschoose another seed pixel which does not yet belong to any region and start not yet belong to any region and start
againagain
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5555
Region Region growing growing
An initial set of small An initial set of small
areas are iterativelyareas are iteratively
merged according to merged according to
similarity constraintssimilarity constraints
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5656
Example defective welds (Example defective welds ( 焊缝焊缝 ) detecting) detecting
X ray of weld (the horizontal dark X ray of weld (the horizontal dark region) containing several cracks region) containing several cracks and porosities (and porosities ( 孔孔 the bright w the bright white streaks running horizontally hite streaks running horizontally through the image)through the image)
We need initial seed points to groWe need initial seed points to grow into regionsw into regions
On looking at the histogram aOn looking at the histogram and image cracks are brightnd image cracks are bright
Select all pixels having value oSelect all pixels having value of 255 as seedsf 255 as seeds
SeedSeed pointspoints
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5757
CriterionCriterion
There is a valley at around 190 in the There is a valley at around 190 in the
histogram A pixel should have a valuehistogram A pixel should have a valuegtgt190 190
to be considered as a part of region to the to be considered as a part of region to the
seed pointseed point
The pixel should be a 8-connected neighbor The pixel should be a 8-connected neighbor
to at least one pixel in that regionto at least one pixel in that region
Result of region growing and boundaries of Result of region growing and boundaries of
defectsdefects
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5858
Region SplittingRegion Splitting
The opposite approach to region mergingThe opposite approach to region merging A top-down approach and starts with the assumA top-down approach and starts with the assum
ption that the entire image is homogeneousption that the entire image is homogeneous
If this is not true the image is split into four sub iIf this is not true the image is split into four sub imagesmages
This splitting procedure is repeated recursivelyThis splitting procedure is repeated recursively(( 递归的递归的 ) until the image is split into homogeneo) until the image is split into homogeneous regionsus regions
Need homogeneity criterion split ruleNeed homogeneity criterion split rule
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
5959
Region SplittingRegion Splitting
DisadvantageDisadvantage
they create regions that may be adjacent they create regions that may be adjacent
and homogeneous but not mergedand homogeneous but not merged
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
6060
Region Splitting and MergingRegion Splitting and Merging
ProcedureProcedure
11 Split image into 4 disjointed quadrants for Split image into 4 disjointed quadrants for any region Rany region Rii P(R P(Rii)=FALSE)=FALSE
22 Merge any adjacent regions RMerge any adjacent regions Rjj and R and Rkk for w for which P(Rhich P(RjjcupRcupRkk)=TRUE)=TRUE
33 Stop when no further splitting or merging iStop when no further splitting or merging is possibles possible
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
6161
Region Splitting and Merging
Quadtree
(四叉树 )
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-
6262
PP((RRii) = TRUE if at least 80 of the pixels in ) = TRUE if at least 80 of the pixels in RRii have t have the property |he property |zzjj--mmii|le2σ|le2σii
where zwhere zjj is the gray level of the is the gray level of the jjth pixel in th pixel in RRii
mmii is the mean gray level of that region is the mean gray level of that region
σσii is the standard deviation of the gray levels in is the standard deviation of the gray levels in RRii
ExampleExample
Original Original
imageimageThresholded imageThresholded image Result of Result of
Splitting and Splitting and
MergingMerging
- Slide 1
- Slide 2
- Slide 3
- Slide 4
- Slide 5
- Slide 6
- Slide 7
- Slide 8
- Slide 9
- Slide 10
- Slide 11
- Slide 12
- Slide 13
- Slide 14
- Slide 15
- Slide 16
- Slide 17
- Slide 18
- Slide 19
- Slide 20
- Slide 21
- Slide 22
- Slide 23
- Slide 24
- Slide 25
- Slide 26
- Slide 27
- Slide 28
- Slide 29
- Slide 30
- Slide 31
- Slide 32
- Slide 33
- Slide 34
- Slide 35
- Slide 36
- Slide 37
- Slide 38
- Slide 39
- Slide 40
- Slide 41
- Slide 42
- Slide 43
- Slide 44
- Slide 45
- Slide 46
- Slide 47
- Slide 48
- Slide 49
- Slide 50
- Slide 51
- Slide 52
- Slide 53
- Slide 54
- Slide 55
- Slide 56
- Slide 57
- Slide 58
- Slide 59
- Slide 60
- Slide 61
- Slide 62
-