Sobel Edge detectors

Discussion in 'Java' started by deepsri.88, Nov 7, 2010.

  1. deepsri.88

    deepsri.88

    Joined:
    Nov 7, 2010
    Messages:
    1
    Hi Everyone! I have an jpeg image and do edge detection on this image. I plan to use sobel edge detector to help me. I have
    just gotten the JAI API. I realized that they have a Packages.javax.media.jai package with KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL and KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL.
    I believe that using this will make implementing the edge detection easier.
    I have written the code below but I get an error and nothing is outputted.


    import java.awt.*;
    import java.awt.image.*;
    import java.io.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.event.*;
    import javax.media.jai.*;
    import javax.media.jai.PlanarImage;
    import javax.media.jai.JAI;
    import java.awt.image.renderable.ParameterBlock;

    public class test {


    public static void loadImage() {
    //Loads the image from the given path and filename
    //this.img = (PlanarImage)JAI.create("fileload", "C:/pic/pic2.jpg");
    PlanarImage img =(PlanarImage)JAI.create("fileload", "C:/pic/pic2.jpg");
    KernelJAI sobelHorizontalKernel = KernelJAI.GRADIENT_MASK_SOBEL_HORIZONTAL;
    KernelJAI sobelVerticalKernel = KernelJAI.GRADIENT_MASK_SOBEL_VERTICAL;
    ParameterBlock pb = new ParameterBlock();
    pb.addSource(img);
    pb.add(sobelHorizontalKernel);
    pb.add(sobelVerticalKernel);
    PlanarImage image = JAI.create("gradientmagnitude",pb, null);
    //canvas.set(image);
    JAI.create("filestore", image, "edge.jpg", "JPEG");
    }



    public static void main(String args[])
    {
    loadImage();



    }
    }


    This keeps giving some error. Not sure on how to solve it. I m a newbie at this and hope someone could help me point out on what I might have done wrong.

    Thanks in advance :)
     
    deepsri.88, Nov 7, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ferdi Smit
    Replies:
    0
    Views:
    792
    Ferdi Smit
    Oct 10, 2005
  2. dashdingo

    3x3 sobel edge detection

    dashdingo, Jun 12, 2007, in forum: VHDL
    Replies:
    3
    Views:
    6,000
    minhhn0205
    Sep 26, 2009
  3. rossalbi

    vhdl sobel for FPGA

    rossalbi, Dec 11, 2007, in forum: VHDL
    Replies:
    2
    Views:
    895
    sprocket
    Dec 12, 2007
  4. denish
    Replies:
    5
    Views:
    5,755
  5. kumar9422

    edge detection using sobel

    kumar9422, May 29, 2010, in forum: VHDL
    Replies:
    0
    Views:
    1,774
    kumar9422
    May 29, 2010
Loading...

Share This Page