Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I'm doing the following : (Each function calls its corresponding Marvin Plugin.) :

    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");

enter image description here

enter image description here

like image 584
The Eighth Ero Avatar asked May 09 '15 19:05

The Eighth Ero


People also ask

What is Marvin in Java?

Marvin Image Processing Framework Pure Java cross-platform image processing framework that provides features for image and video frame processing, multi-threading image processing, GUI integration, extensibility via plug-ins, unit text automation among other things.

What is the way to compile Marvin application?

In order to compile and run the application, is needed the addition of the framework jar (inside the folder marvin/framework) in the classpath. In the case of using command line, simply add the tag "-classpath ./marvin/framework/marvin_1. 3_rc2. jar" (for the version 1.3 release 2) in the compilation and running.

What is Marvin in software engineering?

Marvin is a cross-platform, open-source image processing framework that aims to provide a high productive environment. The main goal of the framework is to integrate the efforts from researchers, software developers and end-users in order to improve the usage of image processing applications.


1 Answers

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:


(source: sourceforge.net)

leaf_rotated_out.jpg:


(source: sourceforge.net)

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;
                }
            }
        }
    }
}
like image 191
Gabriel Ambrósio Archanjo Avatar answered Sep 21 '22 07:09

Gabriel Ambrósio Archanjo