Download as pdf or txt
Download as pdf or txt
You are on page 1of 54

Edge Detection: Convolution vs

Morphological Operation
MATERIKULIAH– [9]:
PENGEMBANGAN APLIKASI INFORMATIKA MEDIS
Tim Pengajar:

Chanifah Indah Ratnasari


Izzati Muhimmah
Rahadian Kurniawan
Sri Kusumadewi
Sasaran
• Mahasiswa memantapkan konsep konvolusi
• Mahasiswa mendapat gambaran
penggunaan konvolusi untuk penajaman
fitur

Referensi Utama
 Noah Snavely. Image Filtering.

2
Outline

Penajaman fitur edge melalui konvolusi


Penajaman fitur edge melalui Operasi Morfologi

3
Kasus
Penajaman Fitur
Citra Biner Fitur tepi objek nantinya dapat
Hasil segmentasi pada citra yang digunakan untuk menghitung
telah melewati Gaussian filtering. keliling sel

4
Sifat tepi
• Tepi objek merupakan posisi piksel yang nilai
intensitasnya berubah secara mencolok.
intensity function
image (along horizontal scanline) first derivative

edges correspond to
5
Source: L. Lazebnik extrema of derivative
Outline

Penajaman fitur edge melalui konvolusi


Penajaman fitur edge melalui Operasi Morfologi

6
Theory of Edge Detection

Ideal edge
y
B1 L(x, y ) = x sin θ − y cos θ + ρ = 0
B1 : L( x, y ) < 0
B2 t B2 : L( x, y ) > 0
x
Unit step function:

1 for t > 0
 t
u (t ) =  1 for t = 0 u (t ) = ∫ δ (s )ds
2 −∞
0 for t < 0

Image intensity (brightness):

I (x, y ) = B1 + (B2 − B1 )u ( x sin θ − y cos θ + ρ )


7
Theory of Edge Detection
• Image intensity (brightness):
I (x, y ) = B1 + (B2 − B1 )u (x sin θ − y cos θ + ρ )
• Partial derivatives (gradients):
∂I
= + sin θ (B2 − B1 )δ (x sin θ − y cosθ + ρ )
∂x
∂I
= − cosθ (B2 − B1 )δ (x sin θ − y cosθ + ρ )
∂y

• Squared gradient:
2 2
 ∂I   ∂I 
s( x, y ) =   +   = [(B2 − B1 )δ (x sin θ − y cosθ + ρ )]
2

 ∂x   ∂y 
Edge Magnitude: s ( x, y )
 ∂I ∂I 
Edge Orientation: arctan /  (normal of the edge)
 ∂y ∂x 
8
Rotationally symmetric, non-linear operator
Theory of Edge Detection
• Image intensity (brightness):

I (x, y ) = B1 + (B2 − B1 )u (x sin θ − y cos θ + ρ )


• Partial derivatives (gradients):
∂I
= + sin θ (B2 − B1 )δ (x sin θ − y cosθ + ρ )
∂x
∂I
= − cosθ (B2 − B1 )δ (x sin θ − y cosθ + ρ )
∂y
• Laplacian: 2 2
∂ I ∂ I
∇ I = 2 + 2 = (B2 − B1 )δ ' ( x sin θ − y cosθ + ρ )
2

∂x ∂y
Rotationally symmetric, linear operator
∂I ∂2I
I
∂x ∂x 2 zero-crossing

x
9
x x
Discrete Edge Operators

• How can we differentiate a discrete image?

Finite difference approximations:

∂I 1
≈ ((I i+1, j +1 − I i, j +1 ) + (I i+1, j − I i, j )) I i , j +1 I i +1, j +1
∂x 2ε ε
∂I 1
≈ ((I i +1, j +1 − I i +1, j ) + (I i, j +1 − I i, j )) Ii, j I i +1, j
∂y 2ε

Convolution masks :

∂I 1 −1 1 ∂I 1 1 1
≈ ≈
∂x 2ε ∂y 2ε
−1 1 −1 −1

10
Discrete Edge Operators
• Second order partial derivatives:
2
I i −1, j +1 I i , j +1 I i +1, j +1
∂ I 1
2
≈ 2 (I i −1, j − 2 I i , j + I i +1, j )
∂x ε I i −1, j I i , j I i +1, j
∂2I 1
2
≈ 2 (I i , j −1 − 2 I i , j + I i , j +1 ) I i −1, j −1 I i , j −1 I i +1, j −1
∂y ε

• Laplacian :
2 ∂2I ∂2I
∇ I= 2+ 2
∂x ∂y
Convolution masks :

0 1 0 1 4 1
2 1 1
∇ I≈ 1 −4 1 or 4 − 20 4 (more accurate)
ε2 6ε 2
0 1 0 1 4 1
11
The Sobel Operators
• Better approximations of the gradients exist

– The Sobel operators below are commonly used

-1 0 1 1 2 1
-2 0 2 0 0 0
-1 0 1 -1 -2 -1

12
Penerapan Deteksi Tepi dengan
Operator Sobel
• http://homepages.inf.ed.ac.uk/rbf/HIPR2/sob
el.htm
• Susun matriks kernel sx
• Susun matrix kernel sy
• Gx = konvolusi (I,sx)
• Gy = konvolusi (I,sy)
• Tepi = |Gx|+|Gy|

13
Hasil konvolusi dengan kernel sx

Perhatikan jika tidak dimutlakan, komponen negatif tidak muncul pada Gx

14
Hasil konvolusi dengan kernel sy

Perhatikan jika tidak dimutlakan, komponen negatif tidak muncul pada Gy

15
Hasil Penajaman Fitur Tepi dengan
Operator Sobel

16
17
Comparing Edge Operators
Good Localization
Gradient: Noise Sensitive
Poor Detection
Roberts (2 x 2): 0 1 1 0
-1 0 0 -1

Prewitt (3 x 3):
-1 0 1 1 1 1
-1 0 1 0 0 0
-1 0 1 -1 -1 1
Sobel (5 x 5):
-1 -2 0 2 1 1 2 3 2 1
-2 -3 0 3 2 2 3 5 3 2
Poor Localization
-3 -5 0 5 3 0 0 0 0 0
Less Noise Sensitive
-2 -3 0 3 2 -2 -3 -5 -3 -2 Good Detection
-1 -2 0 2 1 -1 -2 -3 -2 -1
18
Kernel gaussian
• Untuk penapisan derau, dengan kernel
gaussian.
• Untuk penegasan fitur, dapat digunakan
turunan fungsi Gaussian.
1st derivative 2nd derivative
Gaussian of Gaussian of Gaussian

Baik untuk penapisan derau Baik untuk penegasan fitur


(smoothing) (sharpening)

19
Image derivatives
• How can we differentiate a digital image F[x,y]?
– Option 1: reconstruct a continuous image, f, then
compute the derivative
– Option 2: take discrete derivative (finite difference)

How would you implement this as a linear filter?

: 1 -1 : -1
1

20
Source: S. Seitz
Image gradient
• The gradient of an image:
The gradient points in the direction of most rapid increase in intensity

The edge strength is given by the gradient magnitude:

The gradient direction is given by:

• how does this relate to the direction of the edge? 21 Seitz


Source: Steve
2D edge detection filters

derivative of Gaussian (x)


Gaussian

22
Derivative of Gaussian filter

x-direction y-direction

23
Outline

Penajaman fitur edge melalui konvolusi


Penajaman fitur tepi/edge melalui Operasi
Morfologi

24
Operasi Morfologi
• http://homepages.inf.ed.ac.uk/rbf/HIPR2/morops.htm
• Menggunakan teori himpunan untuk memproses citra.
Tipe data citra yang digunakan biasanya binary.
• Dapat digunakan untuk deteksi tepi, penghilangan
derau, peningkatan citra, dan segmentasi.
• Operasi dasar yang sering digunakan adalah
erosion (mengikis objek) dan dilation (memperluas
objek).
• Prosesnya membutuhkan dua masukan: citra biner
dan structuring element ( kernel biner).

25
Mathematic Morphology

mathematical framework used for:


• pre-processing
– noise filtering, shape simplification, ...
• enhancing object structure
– skeletonization, convex hull...
• Segmentation
– watershed,…
• quantitative description
– area, perimeter, ...
26
Z2 and Z3
• set in mathematic morphology represent
objects in an image
– binary image (0 = white, 1 = black) : the element
of the set is the coordinates (x,y) of pixel belong to
the object  Z2
• gray-scaled image : the element of the set is the
coordinates (x,y) of pixel belong to the object and
the gray levels  Z3

27
Basic Set Theory

28
Reflection and Translation

ˆ
B = {w | w ∈ −b, for b ∈ B}
( A) z = {c | c ∈ a + z, for a ∈ A}

29
Logic Operations

30
Example

31
Structuring element (SE)

 small set to probe the image under study


 for each SE, define origo
 shape and size must be adapted to geometric
properties for the objects

32
Basic idea
• in parallel for each pixel in binary image:
– check if SE is ”satisfied”
– output pixel is set to 0 or 1 depending on used
operation

33
How to describe SE
• many different ways!
• information needed:
– position of origo for SE
– positions of elements belonging to SE

34
Basic morphological operations

• Erosion

• Dilation

keep general shape but


• combine to smooth with respect to

– Opening object
– Closening background

35
Erosion

• Does the structuring element fit the set?


erosion of a set A by structuring element B: all z
in A such that B is in A when origin of B=z

A − B = {z|(B)z ⊆ A}
shrink the object

36
Erosion

37
Erosion

38
Erosion

A − B = {z|(B)z ⊆ A}
39
Penerapan Erosi untuk deteksi tepi
• Susun matriks SE
• Terapkan operasi Erosion
Terkikis = (I,SE);
• Tepi = xor(Terkikis, I);

40
41
42
43
44
Perbandingan Tepi: Sobel vs Operasi
Morfologi

45
Dilation

• Does the structuring element hit the set?


• dilation of a set A by structuring element B: all z
in A such that B hits A when origin of B=z

A ⊕ B = { z|( Bˆ )z ∩ A ≠ Φ }
• grow the object

46
Dilation

47
Dilation

48
Dilation

B = structuring element

ˆ
A ⊕ B = {z|(B)z ∩ A ≠ Φ}
49
Dilation : Bridging gaps

50
useful
• erosion
– removal of structures of certain shape and size,
given by SE
• Dilation
– filling of holes of certain shape and size, given by
SE

51
Combining erosion and dilation
• WANTED:
– remove structures / fill holes
– without affecting remaining parts

• SOLUTION:
• combine erosion and dilation
• (using same SE)

52
Erosion : eliminating irrelevant detail

structuring element B = 13x13 pixels of gray level 1


53
Terima kasih

izzati@uii.ac.id

54

You might also like