PCD : Koding Deteksi Tepi Berbasis Java

hello guys uwe kali ini akan share koding netbeans mata KULI ah PCD tentang deteksi tepi.
pertama tama uwe jelasin dulu ya tugas  apa yang di suruh ama si dia hmmm ... Ada 5 jenis deteksi tepi yang di suruh pak satrio hehe yaitu  :
1. Robert
2. Prewette
3. Sobel
4. Laplacian
5. Kirsch

ket : Robert di suruh buat 2 buah
        Prewette di suruh buat 2 buah
        Sobel di suruh buat 2 buah
        Laplacian  di suruh buat 3 buah
        Kirsch di suruh buat 4 bauh

sebelum copy paste koding nya sebaiknya lu lu semua masukin soure code ini di bagian import (paling atas) :

import java.awt.Graphics2D;
import java.awt.image.BufferedImageOp;

sudah ? oke yukk langsung crott

Robert #1 :

 BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,1 };
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(1,2, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
     
        }catch (Exception e ){
            System.out.println(e);
        }

Robert #2 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,
                                             1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(2,1, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Prewette #1 :

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,0,1,
                              -1,0,1,
                             -1,0,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }
    }                                           

Prewette  #2 :

  BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,-1,-1,
                              0,0,0,
                             1,1,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }     

Sobel #1 :

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,0,1,
                             -2,0,2,
                             -1,0,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Sobel #2 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-1,-2,-1,
                             0,0,0,
                             1,2,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Laplacian #1 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {0,1,0,
                             1,-4,1,
                             0,1,0};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        } 

Laplacian #2:

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {1,1,1,
                             1,-8,1,
                             1,1,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Laplacian #3 :

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {1,2,1,
                             2,-12,2,
                             1,2,1};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }


Kirsch #1 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-5,3,3,
                             -5,0,3,
                             5,3,3};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Kirsch #2 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-5,-5,3,
                             -5,0,3,
                             3,3,3};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Kirsch #3 :

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {3,-5,-5,
                             3,0,-5,
                             3,3,3};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }

Kirsch #4 : 

BufferedImage bi = null ;
    try {
        image = new ImageIcon(sumberGambar).getImage();
        size = new Dimension ();
        size.width = image.getWidth(null);
        size.height= image.getHeight(null);
        setPreferredSize(size);
  prossesImage = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   prosesimage3 = new BufferedImage(size.width, size.height, BufferedImage.TYPE_INT_RGB);
   Graphics g = prossesImage.createGraphics();
        g.drawImage(image,0,0, null);
        jLabel1.setIcon(new ImageIcon (prossesImage));
        bi = new BufferedImage ( image.getWidth(null),image.getHeight(null), BufferedImage.TYPE_BYTE_GRAY);
       Graphics2D g2 = bi.createGraphics();
        g2.drawImage(image,null,null);
        float[] edgeKernel = {-5,-5,-5,
                             3,0,3,
                             3,3,3};
        BufferedImageOp edgeop = new ConvolveOp(new Kernel(3,3, edgeKernel),ConvolveOp.EDGE_NO_OP,null);
        BufferedImage image3 = edgeop.filter(bi,null);
        jLabel2.setIcon(new ImageIcon(image3));
        
        }catch (Exception e ){
            System.out.println(e);
        }
     

Oke tinggal di comot aja gan koding nya untuk laporan kang ming sun yaaa maaf kalo ada salah koding atau ada koding yang tak berkenan di netbeans sistah and brodah hehee sekian terimakasih.

Komentar

Postingan populer dari blog ini

Makalah Algoritma Hough Transform & Source Code

Pengolahan Citra Digital : Laporan Praktikum Jobsheet 3

Pengolahan Citra Digital : Laporan Jobsheet 5