Find Edges with ImageJ Programmatically

人走茶凉 提交于 2019-12-31 02:54:30

问题


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.


回答1:


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();



回答2:


ImageProcessor is an abstract class, that lets the derived classes provide the appropriate implementation. You need to declare ip as type ColorProcessor:

ColorProcessor ip = new ColorProcessor(ip1.getWidth(), ip1.getHeight()); 
ip.findEdges();


来源:https://stackoverflow.com/questions/10652578/find-edges-with-imagej-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!