1 / 22

Deteksi Tepi

Deteksi Tepi. Achmad Basuki Politeknik Elektronika Negeri Surabaya PENS-ITS. Tujuan. Bagaimana mendapatkan garis-garis tepi suatu obyek gambar. Differensial. x(n). 1. n. 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. Menggunakan formulasi h(n)=x(n)-x(n-1) diperoleh:. x(n). n. 0.

adanna
Download Presentation

Deteksi Tepi

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Deteksi Tepi Achmad Basuki Politeknik Elektronika Negeri Surabaya PENS-ITS

  2. Tujuan Bagaimana mendapatkan garis-garis tepi suatu obyek gambar

  3. Differensial x(n) 1 n 0 1 2 3 4 5 6 7 8 9 10 11 Menggunakan formulasi h(n)=x(n)-x(n-1) diperoleh: x(n) n 0 1 2 3 4 5 6 7 8 9 10 11

  4. Differensial Horisontal 1 (-1) (0) + (1) (1) 0 0 1 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 Setiap pixel dikurangi dengan nilai pixel sebelah kirinya 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1

  5. Differensial Vertikal -1 (-1) (1) + (1) (0) 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 Setiap pixel dikurangi dengan nilai pixel sebelah kirinya 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 -1 0 0 0 0 0 0 1 0 0 0 -1 0

  6. Kernel Differensial H/W Kernel Differensial Horizontal -1 1 H= Kernel Differensial Vertikal -1 H= 1

  7. Implementasi Label1 Label2 Picture2 Picture1 FORM PROPERTY: (1) BorderStyle = None (2) ScaleMode = Pixel

  8. Implementasi Code Private Sub Form_Load() Dim xg(320, 240) As Integer 'Mengubah ke gray scale For i = 0 To Picture1.ScaleWidth - 1 For j = 0 To Picture1.ScaleHeight - 1 w = Picture1.Point(i, j) r = w And RGB(255, 0, 0) g = Int((w And RGB(0, 255, 0)) / 256) b = Int(Int((w And RGB(0, 0, 255)) / 256) / 256) xg(i, j) = Int((r + g + b) / 3) Picture1.PSet (i, j), RGB(xg(i, j), xg(i, j), xg(i, j)) Next j Next i 'Deteksi Tepi For i = 1 To Picture1.ScaleWidth - 2 For j = 1 To Picture1.ScaleHeight - 2 z1 = xg(i , j + 1) - xg(i, j - 1) z = Abs(z1) If z > 255 Then z = 255 Picture2.PSet (i, j), RGB(z, z, z) Next j Next i End Sub

  9. Hasil Implementasi

  10. DifferensialMenurut Metode Newton (Metode Numerik) Metode Newton Maju: Differensial h(n) diperoleh dari data x(n+1) dikurangi oleh x(n), ditulis dengan: h(n) = x(n+1) – x(n) Metode Newton Mundur: Differensial h(n) diperoleh dari data x(n) dikurangi oleh x(n-1), ditulis dengan: h(n) = x(n) – x(n-1) Metode Newton Tengahan: Differensial h(n) diperoleh dari setengah data x(n+1) dikurangi oleh x(n-1), ditulis dengan: h(n) = ½ { x(n+1) – x(n-1) }

  11. Differensial HorisontalMetode Newton Tengahan 1 (-1) (0) + (1) (1) H(i,j) = x(i,j+1) – x(i,j-1) 0 0 1 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 1 1 1 0 0 1 0 0 0 0 0 1 1 0 0 0 1 0 0 0 0 0 1 0 0 0 0 1 Formulasi : H(i,j) = (-1) X(i,j) + (0) X(i,j) + (1) X(i,j+1)

  12. Differensial Horisontal/VertikalMetode Newton Tengahan Diff. Horisontal: H(i,j) = (-1) X(i,j-1) + (0) X(i,j) + (1) X(i,j+1) -1 0 1 Kernel  Diff. Horisontal: H(i,j) = (-1) X(i-1,j) + (0) X(i,j) + (1) X(i+1,j) -1 Kernel  0 1

  13. Metode Prewitt Metode ini mengembangkan metode newton tengahan dengan menggunakan kernel yang berupa kernel 2D sebagai berikut: -1 0 1 -1 -1 -1 -1 0 1 0 0 0 -1 0 1 1 1 1 Horisontal Vertikal

  14. Implementasi Code Metode Prewitt Private Sub Form_Load() Dim xg(320, 240) As Integer 'Mengubah ke gray scale For i = 0 To Picture1.ScaleWidth - 1 For j = 0 To Picture1.ScaleHeight - 1 w = Picture1.Point(i, j) r = w And RGB(255, 0, 0) g = Int((w And RGB(0, 255, 0)) / 256) b = Int(Int((w And RGB(0, 0, 255)) / 256) / 256) xg(i, j) = Int((r + g + b) / 3) Picture1.PSet (i, j), RGB(xg(i, j), xg(i, j), xg(i, j)) Next j Next i 'Deteksi Tepi For i = 1 To Picture1.ScaleWidth - 2 For j = 1 To Picture1.ScaleHeight - 2 z1 = xg(i - 1, j + 1) - xg(i - 1, j - 1) z2 = xg(i, j + 1) - xg(i, j - 1) z3 = xg(i + 1, j + 1) - xg(i + 1, j - 1) z = Abs(z1 + z2 + z3) If z > 255 Then z = 255 Picture2.PSet (i, j), RGB(z, z, z) Next j Next i End Sub

  15. Hasil Deteksi TepiMetode Prewitt

  16. Pengembangan Metode Prewitt -1 0 1 -1 -1 -1 -2 -1 0 + = -1 0 1 0 0 0 -1 0 1 -1 0 1 1 1 1 0 1 2 Horisontal Vertikal Gabungan

  17. Implementasi Code Metode Prewitt Private Sub Form_Load() Dim xg(320, 240) As Integer 'Mengubah ke gray scale For i = 0 To Picture1.ScaleWidth - 1 For j = 0 To Picture1.ScaleHeight - 1 w = Picture1.Point(i, j) r = w And RGB(255, 0, 0) g = Int((w And RGB(0, 255, 0)) / 256) b = Int(Int((w And RGB(0, 0, 255)) / 256) / 256) xg(i, j) = Int((r + g + b) / 3) Picture1.PSet (i, j), RGB(xg(i, j), xg(i, j), xg(i, j)) Next j Next i 'Deteksi Tepi For i = 1 To Picture1.ScaleWidth - 2 For j = 1 To Picture1.ScaleHeight - 2 z1 = -2 * xg(i - 1, j - 1) - xg(i - 1, j) z2 = -xg(i, j - 1) + xg(i, j - 1) z3 = xg(i + 1, j) + 2 * xg(i + 1, j + 1) z = Abs(z1 + z2 + z3) If z > 255 Then z = 255 Picture2.PSet (i, j), RGB(z, z, z) Next j Next i End Sub

  18. Perbandingan Hasil METODE PREWITT HORISONTAL METODE PREWITT GABUNGAN

  19. Pengembangan Metode Prewitt -2 -1 0 -1 0 1 -1 0 1 -2 0 2 0 1 2 -1 0 1 Metode Prewitt Gabungan Metode Sobel Horisontal

  20. Metode Sobel Metode ini mengembangkan metode Prewitt dengan menambahkan pembobot gaussian sehingga Metode Sobel ini metode deteksi tepi yang mempunyai kemampuan untuk smoothing -1 0 1 -1 -2 -1 -2 0 2 0 0 0 -1 0 1 1 2 1 Horisontal Vertikal

  21. Implementasi Code Metode Prewitt Private Sub Form_Load() Dim xg(320, 240) As Integer 'Mengubah ke gray scale For i = 0 To Picture1.ScaleWidth - 1 For j = 0 To Picture1.ScaleHeight - 1 w = Picture1.Point(i, j) r = w And RGB(255, 0, 0) g = Int((w And RGB(0, 255, 0)) / 256) b = Int(Int((w And RGB(0, 0, 255)) / 256) / 256) xg(i, j) = Int((r + g + b) / 3) Picture1.PSet (i, j), RGB(xg(i, j), xg(i, j), xg(i, j)) Next j Next i 'Deteksi Tepi For i = 1 To Picture1.ScaleWidth - 2 For j = 1 To Picture1.ScaleHeight - 2 z1 = xg(i - 1, j + 1) - xg(i - 1, j - 1) z2 =2*( xg(i, j + 1) - xg(i, j - 1) ) z3 = xg(i + 1, j + 1) - xg(i + 1, j - 1) z = Abs(z1 + z2 + z3) If z > 255 Then z = 255 Picture2.PSet (i, j), RGB(z, z, z) Next j Next i End Sub

  22. Hasil Metode Sobel

More Related