Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
java中的骨骼化和细化_Java_Image_Image Processing - Fatal编程技术网

java中的骨骼化和细化

java中的骨骼化和细化,java,image,image-processing,Java,Image,Image Processing,我有个问题,我想不出来。 我必须使用两种不同的图像处理技术:和,我必须用java来实现这一点。现在的问题是,我找不到这方面的任何起点或教程。有人能告诉我从哪里开始吗?或者有人能告诉我怎样才能做到这一点?我正在用Java编写应用程序,如果可能的话(当然),我想使用BufferedImage 谢谢您可以像这样绘制BuffereImage: public BufferedImage createSkelethonizationImage() { BufferedImage image = new

我有个问题,我想不出来。 我必须使用两种不同的图像处理技术:和,我必须用java来实现这一点。现在的问题是,我找不到这方面的任何起点或教程。有人能告诉我从哪里开始吗?或者有人能告诉我怎样才能做到这一点?我正在用Java编写应用程序,如果可能的话(当然),我想使用
BufferedImage


谢谢

您可以像这样绘制BuffereImage:

public BufferedImage createSkelethonizationImage() {
   BufferedImage image = new BufferedImage(width, height);
   Graphics2D g2 = image.createGraphics();

   // Perform your drawing here
   g2.drawLine(...);

   g2.dispose();
   return image;
}
要绘制图像,请创建一个扩展JComponent并重写paint方法的新类。以下是一些开始的代码:

public class MyImage extends JComponent {
   // Note: the image should be modified on the Event Dispatch Thread
   private BufferedImage image = createSkelethonizationImage();

   @Override
   public void paint(Graphics g) {
      g.drawImage(image, 0, 0, this);
   }
}
编辑-完整解决方案:

public class Test {

    public static void main(String[] args) {
       // Width and height of your image
       final int width = 200;
       final int height = 200;

       SwingUtilities.invokeLater(new Runnable() {

          @Override
          public void run() {
             JFrame frame = new JFrame();
             MyImage image = new MyImage(width, height);
             frame.add(image);
             frame.setSize(new Dimension(width, height));
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setVisible(true);            
          }
       });
    }
}

class MyImage extends JComponent {

    // Note: image should be modified on the Event Dispatch Thread only
    private final BufferedImage image;

    public MyImage(int width, int height) {
       image = createSkelethonizationImage(width, height);
       setPreferredSize(new Dimension(width, height));
    }

    public BufferedImage createSkelethonizationImage(int width, int height) {
       BufferedImage iamge = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
       Graphics2D g2 = iamge.createGraphics();

       // Perform your drawing here
       g2.setColor(Color.BLACK);
       g2.drawLine(0, 0, 200, 200);

       g2.dispose();
       return iamge;
    }

    @Override
    public void paint(Graphics g) {
       g.drawImage(image, 0, 0, this);
    }
}

您可以像这样绘制BuffereImage:

public BufferedImage createSkelethonizationImage() {
   BufferedImage image = new BufferedImage(width, height);
   Graphics2D g2 = image.createGraphics();

   // Perform your drawing here
   g2.drawLine(...);

   g2.dispose();
   return image;
}
要绘制图像,请创建一个扩展JComponent并重写paint方法的新类。以下是一些开始的代码:

public class MyImage extends JComponent {
   // Note: the image should be modified on the Event Dispatch Thread
   private BufferedImage image = createSkelethonizationImage();

   @Override
   public void paint(Graphics g) {
      g.drawImage(image, 0, 0, this);
   }
}
编辑-完整解决方案:

public class Test {

    public static void main(String[] args) {
       // Width and height of your image
       final int width = 200;
       final int height = 200;

       SwingUtilities.invokeLater(new Runnable() {

          @Override
          public void run() {
             JFrame frame = new JFrame();
             MyImage image = new MyImage(width, height);
             frame.add(image);
             frame.setSize(new Dimension(width, height));
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setVisible(true);            
          }
       });
    }
}

class MyImage extends JComponent {

    // Note: image should be modified on the Event Dispatch Thread only
    private final BufferedImage image;

    public MyImage(int width, int height) {
       image = createSkelethonizationImage(width, height);
       setPreferredSize(new Dimension(width, height));
    }

    public BufferedImage createSkelethonizationImage(int width, int height) {
       BufferedImage iamge = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
       Graphics2D g2 = iamge.createGraphics();

       // Perform your drawing here
       g2.setColor(Color.BLACK);
       g2.drawLine(0, 0, 200, 200);

       g2.dispose();
       return iamge;
    }

    @Override
    public void paint(Graphics g) {
       g.drawImage(image, 0, 0, this);
    }
}

你为什么不把这些算法的一些C实现移植到Java上呢?你能告诉我其中的一些算法吗?你是在寻找一种在Java中处理图像的方法,还是一个关于如何构建执行这些技术的算法的教程?我需要一种在Java中实现这两种技术的方法,或者一些关于如何修改像素的解释。你为什么不把这些算法的一些C实现移植到Java?你能给我指一下这些算法吗?你在寻找一种用Java处理图像的方法吗,或者是关于如何构建执行这些技术的算法的教程?我需要一种在java中实现这两种技术的方法,或者一些关于如何修改像素以获得这些技术的说明。好的,但是我如何才能创建骨架化效果呢?我正在寻找一些开始,以获得这种效果…你将需要要么找到并使用一个库或实现自己的算法。您可能可以使用项目中的源代码。(注意:Jar下载链接已断开,但源代码存在于他们的git站点上。)好的,我会尝试一下,然后我会给出一个答案:)ThanksOk,但是我如何创建骨架化效果呢?我正在寻找一些开始,以获得这种效果…你将需要要么找到并使用一个库或实现自己的算法。您可能可以使用项目中的源代码。(注意:Jar下载链接已断开,但源代码存在于他们的git站点上。)好的,我会尝试一下,我会给出一个答案:)谢谢