การแบ่งขอ้มูลภาพstaff.cs.psu.ac.th/sathit/344-671/image...
TRANSCRIPT
การแบงขอมลภาพ
Image Segmentation
1
เซกเมนเตชน(Segmentation) เปนการแบงขอมลภาพออกเปนสวนยอยๆ ทแตละสวนจะมพนทตอกนไป แตละสวนจะเปนพนทซงอาจจะแทนวตถทอยในภาพ เซกเมนเตชนจะเสรจเมอวตถทตองการ ถกแบงออกไดสมบรณ ผลลพธทไดจากการเซกเมนตจะเปนตวชวดความส าเรจในขนตอนการวเคราะหภาพดวยคอมพวเตอร
2
Introduction • What is image segmentation?
– Technically speaking, image segmentation refers to the decomposition of a scene into different components (thus to facilitate the task at higher levels such as object detection and recognition)
– Scientifically speaking, segmentation is a hypothetical middle-level vision task performed by neurons between low-level and high-level cortical areas
• There is no ground truth to a segmentation task (an example is given in the next slide)
3
Dilemma
input result 1 result 2
What do we mean by “DIFFERENT” objects?
Another example: when we look at trees at a close distance, we consider each of them as a different object; but as we look at trees far away, they merge into one coherent object (woods)
4
Overview of Segmentation Techniques
Texture images
Document images
Medical images
Biometric images
Range images Texture-based
Edge-based
Color-based
Disparity-based
Motion-based
5
Edge-based Techniques
Edge
detection
Segmentation
by boundary
detection
Classification
and analysis
6
Region-Filling
7
Color-Based Techniques
• Color representations
– Device dependent: RGB (displaying) or CMYK (printing)
– Device independent: CIE XYZ or CIELAB (L*a*b*)
• There are different specifications of RGB color spaces (e.g., HP/Microsoft vs. Adobe)
8
Color Space Conversion
Analog TV
Digital TV(MPEG)
9
Data Clustering via Kmeans
Instead of 2D, kmeans can be applied to 3D color space RGB or L*a*b*
10
Texture-based Techniques
What is Texture? No one exactly knows. In the visual arts, texture is the perceived surface quality of an artwork.
11
Disparity-based Techniques
12
Motion Segmentation
13
Document Segmentation
• Document images consist of texts, graphics, photos and so on
• Document segmentation is useful for compression, text recognition
• Adobe and Xerox are the major players
14
Medical Image Segmentation
• Medical image analysis can be used as preliminary screening techniques to help doctors
• Partial Differential Equation (PDE) has been used for segmenting medical images
active contour model (snake)
15
Range Image Segmentation
range intensity ground truth
16
Biometric Image Segmentation
• For fingerprint, face and iris images, we also need to segment out the region of interest
• Various cues can be used such as ridge pattern, skin color and pupil shape
• Robust segmentation could be difficult for poor-quality images
การเซกเมนตภาพในระดบลาง • ขนตอนการเซกเมนตภาพเกรยสเกลจะอาศยหนงในสองคณสมบตพนฐานของคาความเขม นนคอ –ความไมตอเนองและความเปนเนอเดยวกนหรอความเหมอนกน ความไมตอเนองจะถกก าหนดดวยการเปลยนแปลงอยางทนททนใดของคาความเขม เชนขอบ
–สวนความเหมอนกนจะแบงขอมลออกเปนสวนๆโดยแตละสวนจะมเกณฑการวดความเหมอนกนทก าหนดขน
17
• จะใชลาปลาเชยลวนโดวเพอตรวจหาจด • Laplacian masks have the largest 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
18
การตรวจหาจด -1 -1
-1
8
-1
-1
-1
-1
-1
-1 0
0
4
-1
-1
0
-1
0
การตรวจหาขอบ จดและเสน • การตรวจหาความไมตอเนองในภาพระดบสเทาจะไดสวนทเปนขอบ จดและเสน
• การตรวจหาจด
19
การตรวจหาจดอยางงายจะใชตวกรองลาปลาสเมอน าภาพไปคอนโวลชนกบตวกรองกจะไดผลลพธ(รปกลาง) เมอน าไปเทรสโฮลดกจะไดจด (รปขวา)
Location of
porosity
การตรวจหาเสน • การตรวจหาเสนจากรปจะใชตวกรอง −1 − 1 − 1 2 2 2−1 − 1 − 1
−1 − 1 2−1 2 − 1 2 − 1 − 1
−1 2 − 1−1 2 − 1−1 2 − 1
2 − 1 − 1−1 2 − 1−1 − 1 2
• ทใหหาเสนในแนวนอน 45 องศา แนวตง และ –45องศา เมอน าแตละตวกรองไปตรวจหาเสน
ในแตละแนวกจะไดผลลพธดงรป แนวนอน 45 องศา แนวตง 135องศา
20
การตรวจหาเสน (ตอ)
21
เมอน าผลลพธของตวกรองทงสทศทางมารวมกน โดยเลอกเฉพาะคาสงสดจากตวกรองทงสทศกจะได
การตรวจหาเสนดวยการแปลงฮฟ(Hough Transform)
22
• Problem: fit a straight line (or curve) to a set of edge pixels
• Hough transform (1962): generalized template matching technique
• Consider detection of straight lines: 𝑦 = 𝑚𝑥 + 𝑐
Hough transform (cont.)
23
• Subdivide (m,c) plane into discrete “bins,” initialize all bin counts by 0
• Draw a line in the parameter space m,c for each edge pixel x,y and increment bin counts along line.
• Detect peak(s) in (m,c) plane
Hough transform (cont.)
24
Alternative parameterization avoids infinite-slope problem
Similar to Radon transform
Calculation of the Hough transform and its inverse
Hough transform and inverse Hough transform
25
• With the Hough transform with x cos θ + y sin θ = ρ a point (x,y) in the image becomes a sinusoid in the Hough parameter space. • With the inverse Hough transform with x cos θ + y sin θ = ρ a point (ρ,θ) in the Hough parameter space becomes a line in the image.
Discrete implementation and relation to the Radon transform
26
When the loop variables are changed, the Hough transform turns into the Radon transform.
For all (x,y) where f(x,y)!=0 For all (ρ,θ) where x cosθ+y sinθ =ρ H(ρ,θ):= H(ρ,θ) + f(x,y) END
END
The Radon transform are known from computer tomography (CT). It performs line integrals through the object function f(x,y)
For all (r,θ) For all (x,y) where x cosθ+y sinθ =ρ H(ρ,θ):= H(ρ,θ) + f(x,y) END
END
Hough transform
Radon transform
Hough transform Example A
27
Hough transform Example B
28
Hough transform Example C
29
Hough transform example
30
Line detection with the Hough transform
31
a) b) c) d) a) Infrared image of
an airport. b) Thresholded magnitude of the gradient. c) Hough transform
d) Inverse Hough transform of the 3 strongest peeks in c) combined with linking of gaps < 5 pixels. Then overlaid on a).
Circle detection by Hough transform
32
𝑥 − 𝑐12 + 𝑦 − 𝑐2
2 = 𝑐32
ในกรณนเราจะตรวจหาสามตวแปรคอ 𝑐1, 𝑐2และ 𝑐3 ในปรมาตร 𝐴(𝑖, 𝑗, 𝑘) โดยเรมจากใช 𝑐1และ 𝑐2 เพอแกสมการหา 𝑐3 เชนเมอตองการหาจดทเชอมตอกนเปนวงกลม
Hough transform and inverse Hough transform of circles
33
• With the Hough transform with 𝑥 − 𝑐1
2 + 𝑦 − 𝑐22 = 𝑐3
2 a point (𝑐1, 𝑐2) in the image becomes a circle in the Hough parameter space. • With the inverse Hough transform with
𝑥 − 𝑐12 + 𝑦 − 𝑐2
2 = 𝑐32
a point (x,y) in the Hough parameter space becomes a circle in the image.
For all (𝑐1, 𝑐2) where b(𝑐1, 𝑐2)!=0 For all (x,y,c3) where 𝑥 − 𝑐1
2 + 𝑦 − 𝑐22 = 𝑐3
2 c(x,y, c3):= c(x,y, c3) + b(𝑐1, 𝑐2) END END
Hough transform
Calculation of the Hough transform for circles
34
(α − x)2+(β − y)2 = 𝑟2
Example: circle detection by Hough transform
35
Corner detection ->
36
• Harris corner detector
C.Harris, M.Stephens. “A Combined Corner and Edge Detector”. 1988
The Basic Idea ->
37
• We should easily recognize the point by looking through a small window
• Shifting a window in any direction should give a large change in intensity
Harris Detector: Basic Idea ->
38
“flat” region:
no change in
all directions
“edge”:
no change along
the edge direction
“corner”:
significant change
in all directions
Harris Detector: Mathematics ->
39
2
,
( , ) ( , ) ( , ) ( , )x y
E u v w x y I x u y v I x y
Change of intensity for the shift [u,v]:
Intensity Shifted intensity
Window function
or Window function w(x,y) =
Gaussian 1 in window, 0 outside
Harris Detector: Mathematics ->
40
( , ) ,u
E u v u v Mv
For small shifts [u,v] we have a bilinear approximation:
2
2,
( , )x x y
x y x y y
I I IM w x y
I I I
where M is a 22 matrix computed from image derivatives:
Harris Detector: Eigenvalue Analysis ->
41
( , ) ,u
E u v u v Mv
Intensity change in shifting window: eigenvalue analysis
1, 2 – eigenvalues of M
direction of the
slowest change
(max)-1/2 Ellipse E(u,v) = const
direction of the
fastest change
(max)-1/2
(min)-1/2
Eigenvalues Carry Clues ->
42 1
2
“Corner”
1 and 2 are large,
1 ~ 2;
E increases in all
directions
1 and 2 are small;
E is almost constant
in all directions
“Edge”
1 >> 2
“Edge”
2 >> 1
“Flat”
region
Classification of
image points using
eigenvalues of M:
Corner Response Measure ->
43
Measure of corner response:
2
det traceR M k M
1 2
1 2
det
trace
M
M
(k – empirical constant, k = 0.04-0.06)
Note that other definition of corner response measure also exists
Contour plot of Harris cornerness ->
44
Harris Detector: Mathematics ->
45 1
2 “Corner”
“Edge”
“Edge”
“Flat”
• R depends only on
eigenvalues of M
• R is large for a corner
• R is negative with large
magnitude for an edge
• |R| is small for a flat
region
R > 0
R < 0
R < 0 |R| small
การเซกเมนตขอมลภาพเกรยสเกลโดยหาคาพกด (Grey-Scale Thresholding)
46
Grey-Scale Thresholding
Global Thresholding Local Thresholding
Adaptive Thresholding
Global Thresholding ->
47
𝐵 𝑚, 𝑛 = 1, 𝑖𝑓 𝑓 𝑚, 𝑛 ≥ 𝑇
0, 𝑖𝑓 𝑓 𝑚, 𝑛 < 𝑇
ปญหาทส าคญของวธนคอจะหาคา T ทเหมาะสมกบแตละภาพไดอยางไร?
ใชไดดกบภาพทวตถกบฉากหลงแยกกนชดเจน สงเกตได จาก Histogram ของภาพเปนแบบ multimodal
0 50 100 150 200 250
0
100
200
300
400
500
T = 102
สของแบคทเรย
สของฉากหลง
Region based segmentation
48
เปนวธการแยกองคประกอบของภาพโดยดจากต าแหนงของพกเซลและความเหมอนกนของ คณสมบตของพกเซลภายในพนท โดยถาพกเซลทอยตดกนและมคณสมบตเหมอนกนจะถกจด ใหเขากลมเดยวกน ขอดของการท าเชนนจะไดพนททตอเนอง
ตวอยางวธการ Region oriented image segmentation 1. Region Growing
2. Region Splitting and Merging
P
Pixel P and
its neighbors
Connected
pixels
Region Growing Algorithm
49
เรมจาก seed pixel ท าการรวมกลมพกเซลขาง เคยงทมคณสมบตเหมอนกนใหพนทโตขนเรอยๆ
พนทเรมขยายตว
การท างานจะหยดเมอไมสามารถขยายพนทออก ไปไดมากกวาน (เมอชนกบขอบของวตถ)
Watershed Transform -> • ในทางภมศาสตร
watershed เปนสนปนน า ทแยกอางน าในแตละแหลง
• แนวคดของ Watershed transform ทใชในการประมวลผลภาพเกรยสเกล จะใชในการแบงแยกวตถในภาพ โดยใชหลกการเดยวกบอางเกบน า
50
Watershed Transform ->
51
จากภาพ เมอระดบน าในอางเพมขนเรอยๆ กจะเหนเฉพาะขอบของอางเกบน า • เมอเทยบกบภาพเกรยสเกล
คาความเขมในแตละพนทจะไมเทากน สวนทเปนทลม กคอพนททมคาความเขมนอย
• สวนน าจะเปรยบไดกบระดบคาเทรสโฮลด เมอก าหนดใหคาสงขนกจะคลมพนทไดมากขน และจะใชแบงแตละพนทออกจากกน