使用Java中的Marvin Framework删除轮廓

The*_*Ero 17 java pattern-recognition image-processing marvin-framework

我正在使用Marvin Framework来获取静脉图案,但我不知道如何去除叶子轮廓

我正在做以下事情:(每个函数调用其相应的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");
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

在此输入图像描述

Gab*_*njo 1

我开发了一种简单的方法,可能会对您有所帮助。它只是从左到右和从右到左删除叶子边框。

唯一的影响是叶子方向。我已手动旋转您的输出图像。但是,我认为您应该考虑处于该位置的叶子以便进行更好的分析。

叶子旋转.jpg:


(来源:sourceforge.net

leaf_rotated_out.jpg:


(来源:sourceforge.net

源代码:

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;
                }
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

  • 你所说的“目标”是什么意思?这是一种练习吗?问题的定义是什么? (3认同)