Sobel Edge detectors

Joined
Nov 7, 2010
Messages
1
Reaction score
0
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 :)
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top