+ All Categories
Home > Documents > Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation...

Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation...

Date post: 13-Oct-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
46
Image Segmentation I Hongkai Xiong Department of Electronic Engineering Shanghai Jiao Tong University 2016 http://ivm.sjtu.edu.cn
Transcript
Page 1: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Image Segmentation I

Hongkai XiongDepartment of Electronic EngineeringShanghai Jiao Tong University

2016

http://ivm.sjtu.edu.cn

Page 2: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn2

Preview

• Segmentation is to subdivide an image into its component regions or objects.

• Segmentation should stop when the objects of interest in an application have been isolated.

Page 3: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Preview

• Example

3

Page 4: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn4

Preview

• Segmentation algorithms generally are based on one of 2 basis properties of intensity values

▫ discontinuity : to partition an image based on sharp changes in intensity (such as edges)

▫ similarity : to partition an image into regions that are similar according to a set of predefined criteria.

Page 5: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Topic

Edge Detection

• Gradient-based methods

• Canny edge detector

• Hough transform

Page 6: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn6

Detection of Discontinuities

• Detect the three basic types of gray-level

discontinuities

points , lines , edges

Page 7: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Detection of Discontinuities

• What are their characteristics of points, lines, and edges ?

Page 8: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Page 9: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

• We can arrive at the following conclusions:1. 1-st order derivatives usually produce thicker edges;

2. 2-nd order derivatives have a stronger response to fine

details, such as thin lines, isolated points, and noise.

3. 2-nd order derivatives produce a double-edge response at

ramp and step transitions in intensity.

Detection of Discontinuities

Page 10: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn10

Point Detection

A point can be detected at the location where has a

stronger 2-nd derivatives, which can be implemented by

convolving with the mark and having response:

|R| T

where T is a nonnegative threshold

R is the sum of products of the coefficients with the gray levels contained in the region encompassed by the mark.

Page 11: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Line Detection

• Horizontal mask will result with max response when a line passed through the middle row of the mask with a constant background.

• the similar idea is used with other masks.• note: the preferred direction of each mask is weighted with a

larger coefficient (i.e.,2) than other possible directions.

Page 12: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn12

Line Detection

• If we are interested in detecting all lines in an image in one direction, we simply run corresponding mask through the image and threshold the absolute value of the result.

• The points that are left are the strongest responses, which, for lines one pixel thick, correspond closest to the direction defined by the mask.

Page 13: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn13

Example

Page 14: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Focus on Edge

• What is an edge ?

Page 15: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Page 16: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn16

zero-crossing

Character of an edge

Page 17: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

• We can arrive at the following conclusions:

1. 1-st order derivatives usually produce thicker

edges;

2. 2-nd order derivatives have a stronger response to fine

detail, such as thin lines, isolated points, and noise.

3. 2-nd order derivatives produce a double-edge

response at ramp and step transitions in intensity.

Review the conclusions:

Page 18: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

• We find a way to detect edges! Yeh!

Just use 1-st derivatives or

zero-crossing points of 2-nd

derivatives.

Edge detection

Really?

Page 19: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

How about noisy image?First column: images and gray-

level profiles of a ramp edge

corrupted by random Gaussian

noise of mean 0 and = 0.0, 0.1,

1.0 and 10.0, respectively.

Notation:

Fairly little noise can have such a

significant impact on the two key

derivatives used for edge detection

in images

Image smoothing is necessary!

Page 20: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Gradient-based edge detection

• Procedure:

1. Image smoothing for noise reduction.

2. Detection of edge points. Using 1-st or 2-nd

derivatives.

3. Edge localization. To select from the candidate

edge points that are true members of edge set.

Page 21: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn21

1-st order Gradient Operator

• First derivatives are implemented using the magnitude of the gradient.

y

fx

f

G

G

y

xf

21

22

21

22 ][)f(

y

f

x

f

GGmagf yx

the magnitude becomes nonlinearyx GGf

commonly approx.

Page 22: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn22

Gradient Masks

Page 23: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn23

Diagonal edges detect mask

Page 24: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn24

Example

Page 25: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn25

Example

Page 26: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn26

Example

Page 27: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

2-nd order gradient operator

• Laplacian

2

2

2

22 ),(),(

y

yxf

x

yxff

)],(4)1,()1,(

),1(),1([2

yxfyxfyxf

yxfyxff

Page 28: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn28

• Laplacian of Gaussian (LoG)

1.First using Gaussian function to smooth image, then applying Laplacian operator.

According to linear property, we can change the order.

2-nd order gradient operator

𝛻2(𝐺(𝑥, 𝑦 ∗ 𝐼(𝑥, 𝑦 = (𝛻2𝐺(𝑥, 𝑦 ∗ 𝐼(𝑥, 𝑦

Page 29: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn29

LoG

the coefficient must be sum to zero

Page 30: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

2-nd order gradient operator

• Laplacian of Gaussian (LoG)

2. Calculate the zero-crossing points.3. Threshold.

Page 31: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

2-nd order gradient operator

• Difference of Gaussian (DoG)

LoG is complicated, we can approximate the LoG filtering by a DoG operator.

Page 32: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

2-nd order gradient operator

Page 33: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Canny Edge Detector

• The optimal one:

So far, canny operator has been considered as the best of

edge detector.

• Four Steps:

1. Image smoothing using Gaussian filter;

J = I ∗G

2. Calculating the magnitude M and direction D of J.

Page 34: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

3. Non-maxima suppression• Let d1, d2, d3, d4 denote four basic edge directions

(00,450,900,1350), then for each point (x,y) in D:

I. find direction dk which best approximates the direction of

D(x,y).

II. Along the direction dk, check the two neighbors of pixel

[x,y] in M. If M[x,y] is greater than both of its neighbors, set I

[x,y] = M[x,y]; otherwise, I [x,y] = 0.

Canny Edge Detector

Page 35: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Check if pixel is local maximum along gradient direction

Canny Edge Detector

Page 36: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

• Double threshold and edge linkChoose two thresholds Th and TL such that Th >TL,and

threshold I with Th and TL respectively:

Then eliminate from all the nonzero pixels from :

Canny Edge Detector

𝐼𝐻(𝑥, 𝑦 = 𝐼(𝑥, 𝑦 ≥ 𝑇ℎ

𝐼𝐿(𝑥, 𝑦 = 𝐼(𝑥, 𝑦 ≥ 𝑇𝑙

𝐼𝐿 𝐼𝐻

Page 37: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

• Double threshold and edge linkAfter the thresholding operation, all strong pixels in are

assumed to be valid edge pixels and marked immediately.

However, such pixels have gaps, we link edge as follows:

(a) Locate the next unvisited edge pixel p in .

(b) Mark as valid edge pixels all the weak pixels in that are

connected to p.

(c) If all nonzero pixels in have been visited, go to (d),else

to (a).

(d) Set to zero all pixels in that are not marked as valid edge

pixels.

Canny Edge Detector

𝐼𝐿

𝐼𝐻

𝐼𝐻

𝐼𝐻

𝐼𝐿

Page 38: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Hysteresis thresholding

Use a high threshold to start edge curves and a low threshold to

continue them.

Page 39: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Canny with Canny with original

The choice of depends on desired behavior

• large detects large scale edges

• small detects fine features

Canny Edge DetectorEffect of (Gaussian Kernel Size)

Page 40: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Hough Transform

Edge detection yields sets of pixels lying on edge. We

use Hough transform to link them.

Page 41: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

x

y

m

b

m0

b0

image space Hough space

• Connection between image (x, y) and Hough (m ,b) spaces

▫ A line in the image corresponds to a point in Hough space

▫ To go from image space to Hough space:

given a set of points (x,y), find all (m,b) such that y = mx + b

▫ What does a point (x0, y0) in the image space map to?

Hough Transform

Page 42: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Hough Transform

Page 43: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Hough Transform Algorithm

• Typically use a different parameterization

▫ d is the perpendicular distance from the line to the origin

▫ is the angle this perpendicular makes with the x axis

Page 44: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Example

Page 45: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Considering question

• Problem 10.23 (don’t need to hand in)

Page 46: Image Segmentation Imin.sjtu.edu.cn/files/courses/DIP16/Lecture09_1.pdf · •Segmentation algorithms generally are based on one of 2 basis properties of intensity values discontinuity:

http://ivm.sjtu.edu.cn

Thank You!


Recommended