【问题标题】:Find Edges with ImageJ Programmatically以编程方式使用 ImageJ 查找边缘
【发布时间】:2012-05-18 12:23:07
【问题描述】:

我想使用 ImageJ 的查找边选项,拥有边找到的数组并以编程方式将其保存到另一个文件中。

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

但是,findEdges 函数是抽象的,我无法获得边缘找到的图像。

编辑:

我写了以下几行:

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

但是,当我尝试打印 BufferedImage 的 RGB 值时,它只为每个像素 RGB 打印“-16777216”。

【问题讨论】:

  • 另见相关Q&A

标签: java edge-detection imagej


【解决方案1】:

好的,我得到了解决方案,问题是我没有将 ColorProcessor 与图像连接。

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

【讨论】:

  • 如果您这样做,您可以像在问题中所做的那样将ip 声明为ImageProcessor
  • 初始化的左侧在这里无关紧要,因为它只是对内存块的引用。右手边是实际的类,操作将首先查找,所以你说的是对的。
【解决方案2】:

ImageProcessor 是一个抽象类,它让派生类提供适当的实现。您需要将ip 声明为ColorProcessor 类型:

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

【讨论】:

  • 我怎样才能到达边缘发现的数组?我也是用 ColorProcessor 初始化的,我猜它会先在 vtable 中查看 ColorProcessor 的函数。
  • 我不是 ImageJ 专家,但看着 documentation 似乎没有办法做到这一点。而是findEdges() 对图像应用了变换,这样当您获得图像时(例如通过createImage()),您将看到检测到的边缘,而不是原始图像。
  • 非常感谢您的努力,但我得到了解决方案。如果有兴趣,请在下面发布。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-07-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-09
  • 2012-03-26
相关资源
最近更新 更多