Search code examples
javaedge-detectionimagej

Find Edges with ImageJ Programmatically


I want to use find edges option of the ImageJ, have the edges-found array and save it to another file programatically.

ImagePlus ip1 = IJ.openImage("myimage.jpg");
ImageProcessor ip = new ColorProcessor(ip1.getWidth(), ip1.getHeight());
ip.findEdges();

However, the function findEdges is abstract and I can't have the edge-found image.

EDIT:

I wrote the following lines:

ip.findEdges();
BufferedImage bimg = ip.getBufferedImage();

However, when I try to print out the RGB values of the BufferedImage, it only prints "-16777216" for each pixel RGB.


Solution

  • OK, I got the solution, the problem was that I didn't connect the ColorProcessor with the image.

    ColorProcessor ip = new ColorProcessor(ImageIO.read(new File("my_image.jpg")));
    ip.findEdges();
    BufferedImage bimg = ip.getBufferedImage();