You are on page 1of 106

Digital Image Processing

Chapter 10:
Image Segmentation
13 July 2005
Element of Image Analysis

Preprocess
Image acquisition, restoration, and enhancement

Intermediate process
Image segmentation and feature extraction

High level process


Image interpretation and recognition

ISAN-DSP GROUP
Importance of Image Segmentation
Image segmentation is used to separate an image into constituent
parts based on some image attributes. Image segmentation is an
important step in image analysis

Benefit
1. Image segmentation reduces huge amount of unnecessary
data while retaining only importance data for image analysis
2. Image segmentation converts bitmap data into better
structured data which is easier to be interpreted
Image Attributes for Image Segmentation
. Similarity properties of pixels inside the object are used to group
ixels into the same set.
. Discontinuity of pixel properties at the boundary between object
nd background is used to distinguish between pixels belonging to
he object and those of background.
Discontinuity:
Intensity change
at boundary

Similarity:
Internal
pixels share
the same
intensity
Spatial Filtering Application to Shape Detection

 One application of spatial filtering is shape detection: finding


locations of objects with the desired shape.

 Unlike frequency selective masks that are designed based


on the concept of frequency, shape detection masks are
derived from the shapes to be detected themselves.

 A mask for shape detection usually contains the shape or a part


of the shape to be detected.

 The location that is most correlated to the mask is the


location where the highest filter response occurs. The
shape is most likely to exist there.
Point Detection
 We can use Laplacian masks
-1 -1 -1 0 -1 0
for point detection.
-1 8 -1 -1 4 -1
 Laplacian masks have the largest -1 -1 -1 0 -1 0
coefficient at the center of the mask
while neighbor pixels have an
opposite sign.

 This mask will give the high response to the object that has the
similar shape as the mask such as isolated points.

 Notice that sum of all coefficients of the mask is equal to zero.


This is due to the need that the response of the filter must be zero
inside a constant intensity area
Point Detection
Point detection can be done by applying the thresholding function:
1 f ( x , y )  T
g ( x, y )  
0 otherwise

Location of
porosity
X-ray image of the Laplacian image After thresholding
turbine blade with
porosity (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Line Detection

 Similar to point detection, line detection can be performed


using the mask the has the shape look similar to a part of a line

 There are several directions that the line in a digital image can be.

 For a simple line detection, 4 directions that are mostly used are
Horizontal, +45 degree, vertical and –45 degree.

Line detection masks


(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Line Detection Example
Binary wire
bond mask
image

Absolute value
of result after Result after
processing with thresholding
-45 line detector

Notice that –45 degree


lines are most sensitive

(Images from Rafael C.


Gonzalez and Richard E.
Wood, Digital Image
Processing, 2nd Edition.
Edges

Ideal step edge Ideal ramp edge

Blurred edge

Generally, objects and background have different intensities. Therefore,


Edges of the objects are the areas where abrupt intensity changes occur.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Ideal Ramp Edges and its Derivatives

Edge

Original image

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Smoothed Step Edge and Its Derivatives
1.2
Edge

Intensity
0.8
1
Edge
Gray level profile 0.6
0.4
0.2
0
-0.2
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5

0.06 Minimum
0.04
0.02 point
The 1st derivative 0
-0.02
-0.04 Maximum
-0.5point
-0.06
-1.5 -1 0 0.5 1 1.5 2 2.5 3 3.5
x 10 -3 Zero
5
4 crossing
+
3
2
1
+
The 2nd derivative 0
-1 - -
-2
-3
-4
-5
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5
Derivative Based Edge Detection

 From the previous slide, we can conclude that:


Local maxima of the absolute of the 1st derivative and Zero crossing
of the 2nd derivative occur at edges.

 Therefore, for detecting edges, we can apply zero crossing detection


to the 2nd derivative image or thresholding the absolute of the
1st derivative image.

 Nevertheless, derivative operator is very sensitive to noise as we


will see in the next slide.
Noisy Edges and Derivatives

df d2 f Derivative operator is
f(x) a highpass filter and
dx dx 2
thus enhances noise.

AWGN = 0.1

Edge responses
AWGN = 1.0
are buried by
noise.

AWGN = 10
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Masks for Estimating Partial Derivatives

Normally, the mask for estimating partial derivative is anti-


symmetry with respect to the orthogonal axis
For example, the Sobel mask for
computing f is anti-symmetry
x
with respect to the y-axis. It has the
positive sign on the right side and
negative sign on the left side.

Notice that sum of all coefficients is


equal to zero to make sure that the
response of a constant intensity area
is zero.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Masks for Detecting Diagonal Edges

The mask for detecting -45-degree


edges is anti-symmetry with respect to
the –45-degree lines while the mask for
detecting 45-degree edges is
anti-symmetry with respect to the
45-degree lines.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of Image Gradient

f ( x, y ) f
y

f f f

x x y

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of Image Gradient
f ( x, y ) f
y

f f f

x x y

Note: the original image is smoothed by a 5x5 moving average


mask first. (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of Diagonal Edges

Using -45-degree mask Using 45-degree mask

Note: the original image is smoothed by a 5x5 moving average


mask first. (Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Laplacian Masks
The Laplacian masks are used to estimate the Laplacian image:
2 2P 2P
 P 2  2
x y

Ideally, the Laplacian mask must be directional invariant: symmetry in


all direction (radially symmetry ). However, for 3x3 masks, there are
Only 8 possible directions. Hence, we can use the following masks:

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Laplacian Masks
For a large scale Laplacian mask, we can use a Laplacian of Gaussian
(LOG) as a mask:
 x2  y2 
2 2 2  
2  x  y    2
2 
 G ( x, y )    4  e 

  
Surface plot of
LOG, Looks like
a “Mexican hat” LOG image

Cross section 5x5 LOG


of LOG mask
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example of Laplacian Image
The angiogram image
(blood vessels)
P
We can compute the
Laplacian image by:
1. Smooth the image
by the Gaussian mask 1
2
2. Compute the Laplacian
image using the mask
Threshold of Zero crossing
The left image
 2G * P

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Pixel Oriented Image Segmentation: Thresholding

เป็ นวิธีการแยกองค์ประกอบของรู ปภาพโดยดูจากความเหมือนกันของคุณสมบัติของพิกเซลภายใน


พื้นที่เพียงอย่างเดียว เช่นวิธีการ Intensity Thresholding
1 f ( x, y )  T
g ( x, y )  
0 f ( x, y )  T

ใช้ได้ดีกบั ภาพที่วตั ถุกบั ฉากหลังแยกกันชัดเจน สังเกตได้


จาก Histogram ของภาพเป็ นแบบ multimodal
T = 102
500

400
สี ของฉากหลัง
300 สี ของแบคทีเรี ย
200

100

0 50 100 150 200 250


After thresholding
Intensity Thresholding Example

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Automatic Threshold Level Selection
The major problem of intensity thresholding is to find a good
threshold level
Algorithm: effective for bimodal histogram
1. Set initial value of T

2. T1  Average ( p( x, y ) p( x, y )  T )

3. T2  Average ( p( x, y ) p( x, y )  T )

T1  T2
4. T 
2

5. Repeat step 2
Automatic Threshold Level Selection Example

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Multilevel Intensity Thresholding

ในบางกรณี ที่มีวตั ถุที่มีความเข้มต่างกันอาจจำเป็ นต้องใช้ Threshold Level หลายค่า


Histogram
1500
T1 = 158
T2 = 196
1000

500
T3 = 228
0

0 50 100 150 200 250

T1< P <T2 T2< P <T3 P > T3


Noise Problem
เมื่อใช้กบั ภาพที่มีสญ
ั ญาณรบกวน จะทำให้ได้ภาพที่ไม่ต่อเนื่อง
peak ไม่ชดั เจน
Image degraded by Histogram
Gaussian noise ( =12) 250

200
T1 = 158
150
T2 = 196
100

50 T3 = 228
0

0 50 100 150 200 250

T1< P <T2 T2< P <T3 P > T3


Nonuniform Illumination Problem
An image can be expressed as
Reflectance
f ( x, y )  i ( x, y )r ( x, y )
Function r(x,y)
i(x,y) = illumination component
Histogram r(x,y) = reflectance component

Illumination
Function i(x,y)

Image histogram
f(x,y)

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Nonuniform Illumination and Global Thresholding

Global threshold level


Global thresholding of nonuniform
illumination image can cause huge
errors!
Histogram

Nonuniform illumination Global thresholding


image result
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Nonuniform Illumination and Local Thresholding

Local thresholding:
. Divide an image into subimages.
. Threshold each subimage independently
2.1 Compute histogram of each subimage and select a suitable
threshold value for each subimage
2.2 threshold each subimage using a threshold value in 2.1
2.3 Combine all local thresholding results

Error

16 subimages Result of local thresholding


Histogram of Subimages and Local Thresholding
If areas of object and
background are not
balanced, a histogram
will be unimodal.

If areas of object and


background are nearly
equal, a histogram will
be bimodal

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Example of Nonuniform Illumination Problem

เมื่อใช้ภาพที่ความสว่างไม่เท่ากันตลอดภาพ จะทำให้ผลลัพธ์ผดิ ไปอย่างมาก

900

800

700

600

500

400

300

200

100

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1

T=0.4

Error บริ เวณขอบภาพ


ISAN-DSP GROUP
Optimum Thresholding
Background
p1(z) = PDF of object pixels
Object p2(z) = PDF of background pixels

Error due to background pixels E1 (T )   p ( z )dz


2
classified as object pixels is : 


Error due to object pixels
E (T )   p1 ( z )dz
classified as background pixels is: 2
T

Total error = E (T )  P2 E1 (T )  P1E2 (T )

P1 = Probability of occurrence of object pixels


P2 = Probability of occurrence of background pixels
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Optimum Thresholding
Optimum Thresholding

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Optimum Thresholding

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Pixel Oriented Image Segmentation for Color Images

RGB, CMY color models:


Thresholding based on distance in the color space.

HSI color model:


Thresholding based on H and S component mainly.

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Color Segmentation in HSI Color Space
Color image Hue

1 2

3 4

Saturation Intensity
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Segmentation in HSI Color Space (cont.)
Binary thresholding of S component Product of 2 and 5
with T = 10%

5 6

Red pixels

7 8
Histogram of 6 Segmentation of (Images
red color
from Rafaelpixels
C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Color Segmentation in HSI Color Space (cont.)

Color image Segmented results of red pixels

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Color Segmentation in RGB Vector Space

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.

1. Each point with (R,G,B) coordinate in the vector space represents


one color.
2. Segmentation is based on distance thresholding in a vector space

1 if D(c( x, y ), cT )  T
g ( x, y )  
0 if D (c( x, y ), cT )  T

cT = color to be segmented.
D(u,v) = distance function c(x,y) = RGB vector at pixel (x,y).
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Example: Segmentation in RGB Vector Space

Color image

Reference color cT to be segmented


cT  average color of pixel in the box

Results of segmentation in
RGB vector space with Threshold
value
T = 1.25 times the SD of R,G,B values
In the box

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Color Image Segmentation Example

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Pixel Oriented Image Segmentation for Multispectral Images
หลักการของ pixel oriented image segmentation สามารถนำไปใช้กบั ภาพแบบ
multispectrum เช่นภาพสี ได้ โดยการแบ่ง partition ใน Feature space หรื อ
การแยกองค์ประกอบตามสี ของพิกเซลนั้นเอง
Image Domain Partition
ภาพถ่ายเมือง Munich จากอวกาศ Boundary

Blue 0.5

0
1
0.2 0.8
0.4 0.6
0.6
0.4
0.8
From www.jpl.nasa.gov/radar/ 0.2
1 Green
sircxsar/munch.html Red
Feature Space (RGB)
Self Organizing Map for Color Image Segmentation
เราสามารถใช้ Self Organizing Map (SOM) ในการคำนวณหาสี ที่เหมาะสมที่จะใช้
ในการแยกองค์ประกอบตามสี ของพิกเซลได้
ขั้นตอนการหาสี หลัก
1. กำหนดจำนวนสี หลักที่จะใช้แบ่ง
2. กำหนดค่าเริ่ มต้นให้กบั สี หลักทุกสี
3. สำหรับพิกเซลแต่ละพิกเซล นำค่า (R,G,B) มาคำนวณหาระยะทางระหว่างสี หลัก
ทุกสี กับสี ของพิกเซลที่ได้
4. หาสี หลักที่ระยะทางในข้อ 3 ต่ำที่สุด (สี หลักที่ชนะ) สี หลักที่ได้จะเป็ นสี ที่ใกล้เคียง
กับสี ของพิกเซลมากที่สุด ทำการปรับค่าสี ของสี หลักสี น้ นั ในทิศทางเข้าสู่ สีของพิกเซล
5. กลับไปทำข้อ 3-4 จนกระทัง่ ค่าสี ของสี หลักไม่เปลี่ยนแปลงมาก

ขั้นตอนการแยกองค์ ประกอบ
1. สำหรับพิกเซลแต่ละพิกเซล นำค่า (R,G,B) มาคำนวณหาระยะทางระหว่างสี หลัก
ทุกสี กับสี ของพิกเซลที่ได้
2. หาสี หลักที่ระยะทางในข้อ 1 ต่ำที่สุด (สี หลักที่ชนะ) จัดให้พิกเซลนั้นอยูใ่ นกลุ่มของสี หลักที่ชนะ
Self Organizing Map for Color Image Segmentation

ภาพเมือง Munich ประกอบด้วย ผลของการแยกองค์ประกอบตามสี


สี ขาว พื้นที่ส่ิ งก่อสร้างในเมือง
ของรู ปภาพโดยใช้ SOM
สี ม่วง พื้นที่ป่าทึบ
สี เขียวแก่ พื้นที่การเกษตรหนาแน่น
สี ด ำ พื้นที่แหล่งน้ำ
สี ผสม พื้นที่การเกษตรเบาบาง ISAN-DSP GROUP
Advantages and Disadvantage of Pixel Oriented Image Segmentation

ข้อดี
เนื่องจากวิธีการนี้ใช้ขอ้ มูลของคุณสมบัติของพิกเซลเพียงอย่างเดียว
ทำให้ไม่ตอ้ งมีการคำนวณมาก และใช้เวลารวดเร็ ว

ข้อเสี ย
ไม่สามารถใช้กบั ภาพที่มีสญั ญาณรบกวน และภาพที่มีความสว่าง
ไม่คงที่ และผลลัพธ์มกั ได้ภาพที่ไม่ต่อเนื่อง

ISAN-DSP GROUP
Region Oriented Image Segmentation

เป็ นวิธีการแยกองค์ประกอบของภาพโดยดูจากตำแหน่งของพิกเซลและความเหมือนกันของ
คุณสมบัติของพิกเซลภายในพื้นที่ โดยถ้าพิกเซลที่อยูต่ ิดกันและมีคุณสมบัติเหมือนกันจะถูกจัด
ให้เข้ากลุ่มเดียวกัน
ข้อดีของการทำเช่นนี้จะได้พ้ืนที่ที่ต่อเนื่อง
ตัวอย่างวิธีการ Region oriented image segmentation
1. Region Growing
2. Region Splitting and Merging

P
Connected
pixels
Pixel P and
its neighbors
Region Growing Algorithm

เริ่ มจาก seed pixel ทำการรวมกลุ่มพิกเซลข้าง


เคียงที่มีคุณสมบัติเหมือนกันให้พ้ืนที่โตขึ้นเรื่ อยๆ

พื้นที่เริ่ มขยายตัว

การทำงานจะหยุดเมื่อไม่สามารถขยายพื้นที่ออก
ไปได้มากกว่านี้ (เมื่อชนกับขอบของวัตถุ)

ISAN-DSP GROUP
Region Growing Image Segmentation Example

ตัวอย่าง Region growing โดยใช้


กฏการรวมกัน
ถ้าพิกเซลข้างเคียงมีค่าความเข้มของ
แสงต่างกับพิกเซลปัจจุบนั ไม่เกิน 4
เริ่ มต้น ให้จดั อยูใ่ นกลุ่มเดียวกัน
จากภายใน

สิ้ นสุ ด
ISAN-DSP GROUP
ที่ขอบ
Region Growing Image Segmentation Example

Histogram

X-ray image of defective weld

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Region Growing Image Segmentation Example

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Region Splitting and Merging Algorithm

ขบวนการนี้มี 2 ขั้นตอนคือ
1. แบ่งภาพเป็ นภาพย่อยที่ แต่ละภาพย่อย
มีพิกเซลภายในที่คุณสมบัติ uniform
2. รวมภาพที่แบ่งได้เข้าเป็ นกลุ่มตามความ
เหมือนกันของคุณสมบัติของพิกเซล

1. Region Splitting
1. แบ่งภาพตั้งต้นออกเป็ นภาพย่อยๆ
2. สำหรับภาพย่อยแต่ละภาพ ถ้าพิกเซล
ของพื้นที่ภายในยังไม่มีคุณสมบัติเป็ น
หนึ่งเดียวกันให้แบ่งต่อไปเรื่ อยๆ
ISAN-DSP GROUP
Quadtree for Region Splitting Representation

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Region Splitting Algorithm

Region Splitting

ISAN-DSP GROUP
Region Splitting Example

ภาพตั้งต้น

ผลของการทำ Region Spliting โดยให้


standard deviation ของพิกเซลในภาพย่อยไม่เกิน 5
ISAN-DSP GROUP
Region Merging Algorithm
2. Merging
นำภาพย่อยที่แบ่งได้ท้ งั หมดที่มีพิกเซลภายในที่คุณสมบัติเหมือนกันมารวมกัน

ISAN-DSP GROUP
Region Merging Example

ภาพตั้งต้น

ผลของการทำ Region Merging โดยให้


ค่าเฉลี่ยของพิกเซลในภาพย่อยที่จะรวมกันต่างกันไม่เกิน 50
ISAN-DSP GROUP
Region Splitting and Merging Example

(Images from Rafael C. Gonzalez and Richard E.


Wood, Digital Image Processing, 2nd Edition.
Obstacle of Region Oriented Image Segmentation

ปัญหาอุปสรรคของวิธีการ Region Growing


1. การกำหนดกฎเกณฑ์ที่เหมาะสมที่ใช้ตรวจสอบว่าพิกเซลนั้น “มีคุณสมบัติเหมือนกัน”
เพื่อใช้ในการรวมกลุ่มเข้าด้วยกัน
2. การกำหนด seed pixel มีความสำคัญมาก ต้องกำหนดไว้ภายในพื้นที่ที่จะทำการ
แยกองค์ประกอบ
3. การกำหนดกฎเกณฑ์ที่เหมาะสมในการให้โปรแกรมหยุดการทำงานเมื่อพื้นที่ขยาย
ไปถึงขอบของวัตถุ

ปัญหาอุปสรรคของวิธีการ Region Splitting and Merging


1. การกำหนดกฎเกณฑ์ที่เหมาะสมที่ใช้ตรวจสอบว่าพิกเซลทั้งหมดในภาพย่อยแต่ละภาพ
มีคุณสมบัติเป็ นหนึ่งเดียวกันหรื อไม่
2. ต้องการโครงสร้างข้อมูลที่ซบั ซ้อนในการจัดการกับภาพย่อยที่แบ่งได้

ISAN-DSP GROUP
Edge Oriented Image Segmentation

เป็ นวิธีการแยกองค์ประกอบของภาพอาศัยความไม่ต่อเนื่อง (Discontinuity) ของ


คุณสมบัติของพิกเซลบริ เวณรอยต่อระหว่างวัตถุกบั ฉากหลัง วิธีการนี้มุ่งที่ขอบของวัตถุเป็ นหลัก
ผลลัพธ์ที่ได้จากวิธีการนี้ จะอยูใ่ นรู ปเส้นพรมแดนระหว่างพื้นที่ต่างๆ

ความไม่ต่อเนื่องของ
สี บริ เวณรอยต่อ

ISAN-DSP GROUP
Smoothed Step Edge and Its Derivatives
1.2
Edge

Intensity
0.8
1
Edge
Gray level profile 0.6
0.4
0.2
0
-0.2
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5

0.06 Minimum
0.04
0.02 point
The 1st derivative 0
-0.02
-0.04 Maximum
-0.5point
-0.06
-1.5 -1 0 0.5 1 1.5 2 2.5 3 3.5
x 10 -3 Zero
5
4 crossing
+
3
2
1
+
The 2nd derivative 0
-1 - -
-2
-3
-4
-5
-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5 3 3.5
Derivative Based Edge Detection

 From the previous slide, we can conclude that:


Local maxima of the absolute of the 1st derivative and Zero crossing
of the 2nd derivative occur at edges.

 Therefore, for detecting edges, we can apply zero crossing detection


to the 2nd derivative image or thresholding the absolute of the
1st derivative image.

 Nevertheless, derivative operator is very sensitive to noise as we


will see in the next slide.
Masks for Estimating Partial Derivatives

Normally, the mask for estimating partial derivative is anti-


symmetry with respect to the orthogonal axis
For example, the Sobel mask for
computing f is anti-symmetry
x
with respect to the y-axis. It has the
positive sign on the right side and
negative sign on the left side.

Notice that sum of all coefficients is


equal to zero to make sure that the
response of a constant intensity area
is zero.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Gradient Image
Operator ที่เกี่ยวข้องกับอนุพนั ธ์อนั ดับ 1 ของภาพ 2 มิติ คือ Gradient Operator ( )
ซึ่งสามารถใช้ในการตรวจจับขอบได้
2 2
P ˆ P ˆ Gradient  P   P 
P  i j P      
x y Magnitude  x   y 

P P P
ภาพตั้งต้น P
x y
Gradient Vector Field
Gradient เป็ นปริ มาณแบบVector ที่บอกถึง
ขนาดและทิศทางของขอบของวัตถุ

ภาพตั้งต้น

Gradient P พื้นผิวของ P
Vector Pบริ เวณขอบมีลกั ษณะ
Field เหมือนสันเขา ตำแหน่งของ
ขอบคือสันเขา
Gradient Based Image Segmentation

ภาพตั้งต้น

P
P|

Thresholding
ใช้ T มีค่าสูงไป
จะได้ขอบที่ขาด
Edge map บริ เวณมุม

ใช้ T มีค่าต่ำไป
จะได้ขอบที่หนา T=60 T=100
Laplacian Image
Operator ที่เกี่ยวข้องกับอนุพนั ธ์อนั ดับ 2 ของภาพ 2 มิติ คือ Gradient Operator ( )
ซึ่งสามารถใช้ในการตรวจจับขอบได้
2 2 P 2 P
 P 2  2
x y

2 P 2P
ภาพตั้งต้น P 2 P
x 2 y 2
Laplacian Image
เครื่ องหมายของ เครื่ องหมายของ
 2 Pเป็ นลบ  2 P เป็ นบวก
ภายนอกวัตถุ ภายในวัตถุ

ภาพตั้งต้น P 2 P

พื้นผิวของ P
 2
Laplacian Based Image Segmentation

ภาพตั้งต้น

P 2 P

Zero
Crossing
Detection Zero crossing
Detection ทำได้
โดยทำ thresholding
Edge map กับ  2 Pโดยใช้ T=0

Laplacian
ขยายสัญญาณรบกวน
ให้ชดั เจนขึ้น ISAN-DSP GROUP
Gradient VS Laplacian

Gradient Laplacian
P P
ผลตอบสนองต่อขอบแบบขั้น Local Extrema Zero Crossing
(step edge) ของวัตถุ of |P|
ความสำคัญ บอกถึงทิศทางและ บอกถึงตำแหน่งของขอบ
ขนาดของขอบของวัตถุ ของวัตถุ
การตรวจจับขอบ Thresholding Zero Crossing
|P| Detection
จุดอ่อน ผลลัพธ์มกั ได้ edge มักไม่ทนทานต่อสัญญาณ
map ที่ไม่สมบูรณ์ รบกวน

ISAN-DSP GROUP
Boundary Extraction Based on Particle motion in a Vector Field
Gradient field Tangential velocity field

Gradient Vector Field Edge Vector Field


(Hamiltonian Gradient Field)
P ˆ P ˆ P ˆ P ˆ
P  i j P   i  j
x y y x
Edge Vector Field
Tangential velocity field

Edge vector field


มีลกั ษณะเหมือนกระแสน้ำ
P ˆ P ˆ ไหลวนรอบวัตถุ
P   i  j
y x
ISAN-DSP GROUP
Particle Trajectory in an Edge Vector Field
Tangential velocity field

ตำแหน่งของอนุภาคคำนวณได้จาก
  
pk  pk 1   ek 1

pk ตำแหน่งปัจจุบนั ของอนุภาคที่เวลา k

pk 1 ตำแหน่งในอดีตของอนุภาคที่เวลา k-1

ek 1 edge vector field ณ ตำแหน่ง
ที่ pk 1
 ค่าคงที่  > 0
ตำแหน่งเริ่ มต้นของอนุภาค
ผลลัพธ์: ใน edge vector field อนุภาคโคจรรอบวัตถุมีระยะห่างจากวัตถุไกล
ขึ้นเรื่ อยๆ จนเกิดทางเดินรู ปก้นหอย (spiral trajectory)
Example: Particle Trajectory in an Edge Vector Field

ภาพตั้งต้น P

P0

Edge vector field ทางเดินของอนุภาค


dient field Sign of Laplacian image Normal compressive velocity field
A Normal Compressive Vector Field
เพื่อที่จะทำให้อนุภาคเคลื่อนที่ไปตามขอบของวัตถุโดยไม่หลุดไปจากขอบของ
วัตถุ เราต้องการ vector field อีกสนามที่มีคุณสมบัติ “บีบอัด” (normal
compressive) เพื่อบังคับให้อนุภาคเดินตามขอบ
ตัวอย่าง Normal Compressive Field
 1
n  P  2 P
c


P 2
 P n
Example: Normal
A Normal Compressive Vector Field
compressive velocity field
 1
n  P  2 P
c

ISAN-DSP GROUP
Combined Vector Field
t+n
  
v  e   n


v มีลกั ษณะลู่เข้าสู่ขอบ
และไหลวนรอบวัตถุ

ISAN-DSP GROUP
Particle Trajectory in a Combined Vector Field
   
ตำแหน่งของอนุภาค pk  pk 1   ek 1   nk 1
t+n

อนุภาคโคจรรอบวัตถุตาม
เส้นทางเดียว

เราสามารถแกะรอยเส้น
ขอบของวัตถุได้จากทางเดิน
ของอนุภาค

ตำแหน่งเริ่ มต้นของอนุภาค
Example: Particle Trajectory in a Combined Vector Field

Edge vector field  1


n  P  2 P
c

Particle trajectory
   
P0 pk  pk 1   ek 1   nk 1

Shape distortion at a corner


Boundary Extraction of Multiple Objects

1-way boundary extraction 2-way boundary extraction

ถ้าให้อนุภาคเดินไปในทิศทางเดียว
จะมีโอกาสได้เส้นขอบที่ไม่สมบูรณ์ ISAN-DSP GROUP
Boundary Extraction Algorithm Based on Particle
Motion in a Vector Field

1. เลือก Mask ที่เหมาะสมในการคำนวณ Gradient และ Laplacian ของภาพ


2. คำนวณ edge vector field และ normal compressive vector field
3. กำหนดตำแหน่งเริ่ มต้นให้อนุภาค ณ ตำแหน่ง Local maxima ของ
Gradient magnitude image
4. แกะรอยเส้นขอบตามทางเดินของอนุภาค
5. หยุดการทำงานเมื่ออนุภาคเดินกลับมาที่จุดเริ่ มต้นหรื อพบกับเส้นขอบที่เคยผ่านมาแล้ว

ISAN-DSP GROUP
Boundary Extraction Example

(Obtained using multiple scale Gaussian differential


masks with min = 0.5, max = 2.0)

ภาพจาก The whole brain atlas, www.med.harvard.edu/AANLIB/home.html ISAN-DSP GROUP


Boundary Extraction Example: Flaw Detection

Original X-ray image Gradient image

Boundary extraction results (=1.0)


Flaws
Multiscale Boundary Extraction

Gradient images and extracted boundaries

1=0.5 2=4.77 3=18.81


Conclusions

Image segmentation ที่มีประสิ ทธิภาพ จะต้องมีคุณสมบัติสำคัญดังนี้


1. มีขบวนการปรับปรุ งภาพที่ดีเพื่อทำให้ภาพง่ายต่อการแยกองค์ประกอบ
2. ใช้ขอ้ มูลสำคัญให้เป็ นประโยชน์
2.1 คุณสมบัติที่เหมือนกันของพิกเซลภายในพื้นที่เดียวกัน
2.2 คุณสมบัติที่แตกต่างกันของพิกเซลในพื้นที่ที่ต่างกัน
2.3 ตำแหน่งของพิกเซล และการเชื่อมต่อกัน
2.4 ตำแหน่ง ขนาด ทิศทางของรอยต่อระหว่างพื้นที่
2.5 สมมุติฐานเบื้องต้นที่จ ำเป็ น (ความรู้ช้ นั สูง)
3. มีโครงสร้างข้อมูลที่สามารถรองรับวิธีการแยกองค์ประกอบภาพได้
4. ต้องการ user defined parameters น้อยที่สุดเท่าที่จ ำเป็ น

ISAN-DSP GROUP
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
(Images from Rafael C. Gonzalez and Richard E.
Wood, Digital Image Processing, 2nd Edition.
Edge Linking

You might also like