Menu

FelzenszwalbHuttenlocherSegmenter returns 1 connected component

Anonymous
2016-10-01
2016-10-02
  • Anonymous

    Anonymous - 2016-10-01

    I am just starting out with OpenIMAJ (1.3.5) and am trying out the tutorial problem 3.1.2. Exercise 2: A real segmentation algorithm which suggests using the FelzenszwalbHuttenlocherSegmenter. (And this is one of the segmenters that will probably prove relevant to the real problems I am attempting to solve).

    I first tried this with a few of my own images, both as color and grayscale, and in each case the segmenter reported 1 connected component.

    I then tested against the sample images and parameters on Felzenszwalb's home page and these also returned only 1 connected component.

    Please provide some guidance on the proper use of this segmenter if I am doing something incorrectly.

    Thank you,
    David

    Code below:

     public static void main( String[] args ) throws IOException {
    
            URL sampleImageUrl1 = new URL("http://cs.brown.edu/~pff/segment/beach.gif");        
            URL sampleImageUrl2 = new URL("http://cs.brown.edu/~pff/segment/grain.gif");
    
            processDefaultFelzenszwalbImage(sampleImageUrl1,  0.5f, 500f, 50);
            processDefaultFelzenszwalbImage(sampleImageUrl2,  0.5f, 1000f, 100);
    
        }
    
        public static void processDefaultFelzenszwalbImage(URL url, float sigma, float k, int minSize) throws IOException
        {
    
            MBFImage input = ImageUtilities.readMBF(url);
    
            FelzenszwalbHuttenlocherSegmenter<MBFImage> segmenter = new FelzenszwalbHuttenlocherSegmenter<MBFImage>(sigma, k, minSize);
            List<ConnectedComponent> components = segmenter.segment(input);
    
            int componentsCount = components.size();
            System.out.println("Component count " + componentsCount);
    
        }
    
     
  • Jonathon Hare

    Jonathon Hare - 2016-10-01

    I think the problem is with your setting of the k parameter - OpenIMAJ's internal image representation (MBFImage) uses pixel values between 0 and 1, whereas Felzenszwalb's code has images where the pixels are 0-255. If you divide your k value by 255 it should work I believe.

     
  • Anonymous

    Anonymous - 2016-10-01

    Changing the k value as you suggest resolves the issue. Thank you for the quick and helpful response.

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.