Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.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中使用Marvin框架去除轮廓_Java_Image Processing_Pattern Recognition_Marvin Framework - Fatal编程技术网

在Java中使用Marvin框架去除轮廓

在Java中使用Marvin框架去除轮廓,java,image-processing,pattern-recognition,marvin-framework,Java,Image Processing,Pattern Recognition,Marvin Framework,我用它来获取纹理图案,但我不知道如何去除叶子轮廓 我正在做以下工作: (每个函数调用其相应的Marvin插件): 我开发了一种简单的方法,可以帮助您。它只是从左到右和从右到左删除叶边界 唯一的含义是叶子的方向。我已手动旋转您的输出图像。不过,我认为你应该考虑这个位置的叶子,以便更好地分析。< /P> leaf\u旋转。jpg: public class LeafTest { public static void main(String[] args) { Marvi

我用它来获取纹理图案,但我不知道如何去除叶子轮廓

我正在做以下工作: (每个函数调用其相应的Marvin插件):


我开发了一种简单的方法,可以帮助您。它只是从左到右和从右到左删除叶边界

唯一的含义是叶子的方向。我已手动旋转您的输出图像。不过,我认为你应该考虑这个位置的叶子,以便更好地分析。< /P> leaf\u旋转。jpg:

public class LeafTest {

    public static void main(String[] args) {

        MarvinImage image = MarvinImageIO.loadImage("./res/leaf_rotated.jpg");
        removeBorder(image);
        MarvinImageIO.saveImage(image, "./res/leaf_rotated_out.jpg");
    }

    private static void removeBorder(MarvinImage image){

        // left to right
        for(int y=0; y<image.getHeight(); y++){
            for(int x=0; x<image.getWidth(); x++){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2<image.getWidth() && x2 < x+40; x2++){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=0;
                    break;
                }
            }
        }

        // right to left
        for(int y=0; y<image.getHeight(); y++){
            for(int x=image.getWidth()-1; x>=0; x--){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2>=0 && x2 > x-40; x2--){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=image.getWidth()-1;
                    break;
                }
            }
        }
    }
}

(来源:)

leaf\u旋转出。jpg:

public class LeafTest {

    public static void main(String[] args) {

        MarvinImage image = MarvinImageIO.loadImage("./res/leaf_rotated.jpg");
        removeBorder(image);
        MarvinImageIO.saveImage(image, "./res/leaf_rotated_out.jpg");
    }

    private static void removeBorder(MarvinImage image){

        // left to right
        for(int y=0; y<image.getHeight(); y++){
            for(int x=0; x<image.getWidth(); x++){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2<image.getWidth() && x2 < x+40; x2++){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=0;
                    break;
                }
            }
        }

        // right to left
        for(int y=0; y<image.getHeight(); y++){
            for(int x=image.getWidth()-1; x>=0; x--){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2>=0 && x2 > x-40; x2--){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=image.getWidth()-1;
                    break;
                }
            }
        }
    }
}

(来源:)

源代码:

public class LeafTest {

    public static void main(String[] args) {

        MarvinImage image = MarvinImageIO.loadImage("./res/leaf_rotated.jpg");
        removeBorder(image);
        MarvinImageIO.saveImage(image, "./res/leaf_rotated_out.jpg");
    }

    private static void removeBorder(MarvinImage image){

        // left to right
        for(int y=0; y<image.getHeight(); y++){
            for(int x=0; x<image.getWidth(); x++){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2<image.getWidth() && x2 < x+40; x2++){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=0;
                    break;
                }
            }
        }

        // right to left
        for(int y=0; y<image.getHeight(); y++){
            for(int x=image.getWidth()-1; x>=0; x--){

                if(image.getIntComponent0(x, y) > 10){

                    for(int x2=x; x2>=0 && x2 > x-40; x2--){
                        image.setIntColor(x2, y, 0,0,0);
                    }

                    x=image.getWidth()-1;
                    break;
                }
            }
        }
    }
}
公共类测试{
公共静态void main(字符串[]args){
MarvinImage=MarvinImageIO.loadImage(“./res/leaf_rotated.jpg”);
去除边界(图像);
saveImage(image,“./res/leaf_rotated_out.jpg”);
}
私有静态void removeBorder(MarvinImage图像){
//从左到右
对于(int y=0;y=0&&x2>x-40;x2--){
setIntColor(x2,y,0,0,0);
}
x=image.getWidth()-1;
打破
}
}
}
}
}

是的,我已经试过了,但目标是使用marvin插件删除轮廓…你说的“目标”是什么意思?这是练习吗?这个问题的定义是什么?我认为我们应该从黑白图像中减去它的凸包。但我不知道如何在这个框架中正确地进行,我不知道如果不识别背景并防止背景模糊时被包括在内,你怎么能做到这一点。