简体   繁体   English

使用Java中的Marvin Framework删除轮廓

[英]Removing contour using Marvin Framework in Java

I'm using Marvin Framework to get the veins pattern, but I don't know how to remove the leaf contour 我正在使用Marvin Framework来获取静脉图案,但我不知道如何去除叶子轮廓

I'm doing the following : (Each function calls its corresponding Marvin Plugin.) : 我正在做以下事情:(每个函数调用其相应的Marvin插件。):

    MarvinImage source = MarvinImageIO.loadImage("source.jpg");

    MarvinImage gsImage = grayscaleImage(source);

    MarvinImage blImage1 = blurEffect(gsImage.clone(),1);

    MarvinImage blImage2 = blurEffect(blImage1.clone(), 13);

    MarvinImage difi = subtract(blImage2.clone(), blImage1.clone());

    difi = invertC(difi.clone());

    difi = closingEffect(difi.clone());

    difi = MarvinColorModelConverter.binaryToRgb(difi.clone());

    difi = reduceNoise(difi.clone());

    difi = invertC(difi.clone());

    MarvinImageIO.saveImage(difi, "result.jpg");

在此输入图像描述

在此输入图像描述

I've developed a simple approach that may help you. 我开发了一种可以帮助你的简单方法。 It just removes the leaf borders from left to right and from right to left. 它只是从左到右和从右到左移除叶子边框。

The only implication is the leaf orientation. 唯一的含义是叶子方向。 I've rotated your output image manually. 我已手动旋转输出图像。 However, I think you should consider leafs in that position for better analysis. 但是,我认为您应该考虑在该位置使用叶子以便更好地进行分析。

leaf_rotated.jpg: leaf_rotated.jpg:

http://marvinproject.sourceforge.net/other/leaf_rotated.jpg http://marvinproject.sourceforge.net/other/leaf_rotated.jpg

leaf_rotated_out.jpg: leaf_rotated_out.jpg:

http://marvinproject.sourceforge.net/other/leaf_rotated_out.jpg http://marvinproject.sourceforge.net/other/leaf_rotated_out.jpg

SOURCE CODE: 源代码:

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;
                }
            }
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM