CMP 3108, IMAGE PROCESSING LECTURE 8
IMAGE SEGMENTATION
Dr Xujiong Ye
School of Computer Science
InterpolaHon
Enhancement-1
Histogram Processing
Enhancement-2
Sharpening (Sobel & Laplacian)
Image Analysis
Syllabus
Fundamentals
Introduc:on Module IntroducHon, Origins of Image Processing (Imaging), Imaging ModaliHes
Image FormaHon, Pixels, SpaHal & Intensity ResoluHons, Grey Level TransformaHons: Contrast Stretching,
SpaHal Filtering: Smoothing (Averaging, Median),
Morphological Image Processing Image Segmenta:on
Applica:ons
Representa:on and Descrip:on Colour Image Processing
Image Compression
Real-world Applica:ons
Image Acquisi:on
Image Segmenta:on
• SegmentaHon is the process of parHHoning an image into regions with respect to a parHcular applicaHon
Ø region: group of connected pixels with similar properHes
Ø properHes: grey levels, colours, textures, moHon characterisHcs (moHon vectors), edge conHnuity …
Image Segmenta:on
• Common Approaches to SegmentaHon
• edge-based
• search for edges in the image
• edges can be linked to obtain borders between regions
• region-based
• thresholding, region growing, region spliYng & merging,
watershed, etc
• moHon-based
• separate moving foreground objects from background model
Recap: Edge Detec:on
• Edges correspond to large changes in intensity of neighbours pixels in at least one direcHon
I(x)
edge
• 1st order derivaHve has a maximum or minimum on a edge • 2nd order derivaHve has zero crossing on the highest rise
and fall of an edge
edge detection
x
Edge Detec:on
• Edge Detectors
• Prewi\ and Sobel – 1st order derivaHve
• 2 masks approximate |Gx | and |Gy | in • Prewi\
∇f ≈ G2 +G2 x y
θ = tan−1 Gy Gx
-1
0
1
-1
0
1
-1
0
1
-1
-1
-1
0
0
0
1
1
1
Edge Detec:on
• Edge Detectors
• Prewi\ and Sobel
• 2 masks approximate |Gx | and |Gy | in • Sobel
∇f ≈ G2 +G2 x y
θ = tan−1 Gy Gx
-1
0
1
-2
0
2
-1
0
1
-1
-2
-1
0
0
0
1
2
1
Edge Detec:on
• Laplacian – 2nd order • approximaHon to
∇2 = ∂2 f + ∂2 f ∂x2 ∂y2
or
0
1
0
1
-4
1
0
1
0
1
1
1
1
-8
1
1
1
1
Edge Detec:on
Sobel
Sobel
Edge Detec:on
• Noise removal
• necessary because the 1st and 2nd derivaHve are very sensiHve to image noise
Canny Edge Detector
One of the most powerful edge detecHon algorithms
ü Good localiza:on: The distance between edge pixels detected and real edge pixels have to be minimized.
ü Low error rate: Meaning a good detecHon of only existent edges
True Edge
Poor robustness to noise Poor localization Too many responses
Canny Edge Detector
1. Noise reducHon
• 2DGaussianfilterwith
standard deviaHon σ used for smoothing
2. Compute the local gradient and edge direcHon at every point
• DerivaHves Gx and Gy are computed using Sobel, or Prewi\ operators
Canny Edge Detector
3. Thinningofedges(“non-maximumsuppression”)
• Step 2 produces ridges
• The algorithm in this step tracks along the top of these ridges, seYng all other pixels to 0
4. Hysteresis
• Thresholds T1 and T2 are used for thresholding with T1 <
T2
• “Strong pixels” = pixels with values greater than T2
• “Weak pixels” = pixels with values between T1 and T2
• Incorporate weak pixels that are 8-connected to strong pixels --- reduce misses
Canny Edge Detector
• Different parameters for σ, T1 and T2 produce different results (try it in MATLAB)
[g,t] = edge(f, 'canny', [T1,T2], sigma);
Before step 3 and 4
Canny Edge Detector
Edge Based Segmenta:on
• Advantages
o Works well in images with good contrast between object
and background
• Disadvantages
o Does not work well on images with smooth transiHons and
low contrast
o Robust edge linking is required
Region Based Segmenta:on
• MoHvaHon
Ø Regions are important for the interpretaHon of images
because they may correspond to objects in a scene
• Unlike edge-based segmentaHon, which returns boundaries between regions, region-based segmentaHon is a technique that allows us to determine the regions directly
Thresholding-based Segmenta:on
• Thresholding
BW = imbinarize (I, level)
• For all image pixels,
o If pixel value > T, then mark as “object” o Else mark as “background”
• Output is a binary image
Thresholding
How to choose the threshold T?
• Global
• based on histograms
• fixed threshold (the same value is used in the whole image)
• Local or “AdapHve”
• depends on the posiHon in the image
• the image is divided into secHons which are thresholded one by one
Greylevel Histogram-based Segmenta:on
• Global Thresholding – Histograms
Easy…
…and difficult!
The image cannot be displayed. Your computer may not have enough memory to open the image, or the image may have been corrupted. Restart your computer, and then open the file again. If the red x still appears, you may have to delete the image and then insert it again.
Basic Automa:c Thresholding
• AutomaHc Thresholding Algorithm
1. select an iniHal esHmate for T
2. segment the image using T which produces 2 groups: ► G1, pixels with value >T and
► G2 , with value
Thresholding
• Thresholding
• problem: can leave “holes” in segmented objects
• soluHon: post-processing with morphological operators
• thresholding is a special case of pixel classificaHon • 2 classes: 0 or 1 (above or below threshold)
• more than 2 classes: mulHlevel thresholding
Region-based Segmenta:on
• Region Growing
1. find starHng points (“seeds”)
2. include neighbouring pixels with similar features (grey-level, texture, color)
3. conHnue unHl stopping criterion is reached or
all pixels have been included in one of the regions
• Issues
• not trivial to find good starHng points, difficult to
automate
• need good similarity and stopping criteria
InterpolaHon
Enhancement-1
Histogram Processing
Enhancement-2
Sharpening (Sobel & Laplacian)
Image Analysis
Syllabus
Fundamentals
Introduc:on Module IntroducHon, Origins of Image Processing (Imaging), Imaging ModaliHes
Image FormaHon, Pixels, SpaHal & Intensity ResoluHons, Grey Level TransformaHons: Contrast Stretching,
SpaHal Filtering: Smoothing (Averaging, Median),
Morphological Image Processing Image Segmenta:on
Applica:ons
Representa:on and Descrip:on Colour Image Processing
Image Compression
Real-world Applica:ons
Image Acquisi:on
Recommended Reading
“Digital Image Processing”, R.C. Gonzalez and R.E. Woods, 3rd ediHon, Pearson PrenHce Hall, 2008
Chapter 10