Digital Image Processing
Digital Image Processing
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
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
This mask will give the high response to the object that has the
similar shape as the mask such as isolated points.
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
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.
Absolute value
of result after Result after
processing with thresholding
-45 line detector
Blurred edge
Edge
Original image
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
df d2 f Derivative operator is
f(x) a highpass filter and
dx dx 2
thus enhances noise.
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
f ( x, y ) f
y
f f f
x x y
f f f
x x y
Surface plot of
LOG, Looks like
a “Mexican hat” LOG image
400
สี ของฉากหลัง
300 สี ของแบคทีเรี ย
200
100
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
500
T3 = 228
0
200
T1 = 158
150
T2 = 196
100
50 T3 = 228
0
Illumination
Function i(x,y)
Image histogram
f(x,y)
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
900
800
700
600
500
400
300
200
100
T=0.4
Error due to object pixels
E (T ) p1 ( z )dz
classified as background pixels is: 2
T
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.)
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
Results of segmentation in
RGB vector space with Threshold
value
T = 1.25 times the SD of R,G,B values
In the box
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
ข้อดี
เนื่องจากวิธีการนี้ใช้ขอ้ มูลของคุณสมบัติของพิกเซลเพียงอย่างเดียว
ทำให้ไม่ตอ้ งมีการคำนวณมาก และใช้เวลารวดเร็ ว
ข้อเสี ย
ไม่สามารถใช้กบั ภาพที่มีสญั ญาณรบกวน และภาพที่มีความสว่าง
ไม่คงที่ และผลลัพธ์มกั ได้ภาพที่ไม่ต่อเนื่อง
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
พื้นที่เริ่ มขยายตัว
การทำงานจะหยุดเมื่อไม่สามารถขยายพื้นที่ออก
ไปได้มากกว่านี้ (เมื่อชนกับขอบของวัตถุ)
ISAN-DSP GROUP
Region Growing Image Segmentation Example
สิ้ นสุ ด
ISAN-DSP GROUP
ที่ขอบ
Region Growing Image Segmentation Example
Histogram
ขบวนการนี้มี 2 ขั้นตอนคือ
1. แบ่งภาพเป็ นภาพย่อยที่ แต่ละภาพย่อย
มีพิกเซลภายในที่คุณสมบัติ uniform
2. รวมภาพที่แบ่งได้เข้าเป็ นกลุ่มตามความ
เหมือนกันของคุณสมบัติของพิกเซล
1. Region Splitting
1. แบ่งภาพตั้งต้นออกเป็ นภาพย่อยๆ
2. สำหรับภาพย่อยแต่ละภาพ ถ้าพิกเซล
ของพื้นที่ภายในยังไม่มีคุณสมบัติเป็ น
หนึ่งเดียวกันให้แบ่งต่อไปเรื่ อยๆ
ISAN-DSP GROUP
Quadtree for Region Splitting Representation
Region Splitting
ISAN-DSP GROUP
Region Splitting Example
ภาพตั้งต้น
ISAN-DSP GROUP
Region Merging Example
ภาพตั้งต้น
ISAN-DSP GROUP
Edge Oriented Image Segmentation
ความไม่ต่อเนื่องของ
สี บริ เวณรอยต่อ
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
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
ตำแหน่งของอนุภาคคำนวณได้จาก
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
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
Particle trajectory
P0 pk pk 1 ek 1 nk 1
ถ้าให้อนุภาคเดินไปในทิศทางเดียว
จะมีโอกาสได้เส้นขอบที่ไม่สมบูรณ์ ISAN-DSP GROUP
Boundary Extraction Algorithm Based on Particle
Motion in a Vector Field
ISAN-DSP GROUP
Boundary Extraction Example
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