3

I am working on a project which consist of a procedure of "reading diagram by computer" I will need to do image segmentation in order to identify the shapes and their locations in the image input. My professor said that I can use any public image segmentation library to do it. Is there any good image segmentation library which can serve this purpose?

thanks a lot

darrenchiusw
  • 33
  • 1
  • 5

1 Answers1

6

In JAVA for example these tools provide many algorithms for image segmentation:

ImageJ

http://rsbweb.nih.gov/ij/

Fiji

http://fiji.sc/wiki/index.php/Fiji

Rapidminer IMMI

http://www.burgsys.com/image-mining

Marvin Framework

http://marvinproject.sourceforge.net/


COMPLEMENT

Even being generic, I think it is possible to answer this question in some sense. Since this question is closed, I gonna complement @radim-burget answer for those people that get here looking for a simple example of image segmentation in Java.

Image Segmentation is an image processing task and is handled by most image processing frameworks. In the example below I'm using Marvin Framework.

Algorithm to segment diagram elements:

  1. Load image and binarize
  2. Apply morphological erosion to remove lines, texts, etc
  3. Apply floodfill segmentation to get segments
  4. Draw the segments in the original image.

Input:

enter image description here

After Erosion:

enter image description here

Result:

enter image description here

Source Code:

import static marvin.MarvinPluginCollection.*;

public class SegmentDiagram {

    public SegmentDiagram(){
        MarvinImage originalImage = MarvinImageIO.loadImage("./res/diagram.png");
        MarvinImage image = originalImage.clone();
        MarvinImage binImage = MarvinColorModelConverter.rgbToBinary(image, 250);
        morphologicalErosion(binImage.clone(), binImage, MarvinMath.getTrueMatrix(5, 5));
        image = MarvinColorModelConverter.binaryToRgb(binImage);
        MarvinSegment[] segments = floodfillSegmentation(image);

        for(int i=1; i<segments.length; i++){
            MarvinSegment seg = segments[i];
            originalImage.drawRect(seg.x1, seg.y1, seg.width, seg.height, Color.red);
            originalImage.drawRect(seg.x1+1, seg.y1+1, seg.width, seg.height, Color.red);
        }
        MarvinImageIO.saveImage(originalImage, "./res/diagram_segmented.png");
    }

    public static void main(String[] args) {
        new SegmentDiagram();
    }
}

The shape recognition is another topic, already discussed on Stack Overflow:

2D Shape recognition algorithm - looking for guidance

Community
  • 1
  • 1
Radim Burget
  • 1,456
  • 2
  • 20
  • 39