Results 1 to 8 of 8

Thread: Segment an image in java

  1. #1
    Join Date
    Dec 2009
    Posts
    211

    Segment an image in java

    Hello,
    I have a small problem with my code. I try to write java code to segment an image using the region growing approach. when I run the code it gives me exceptions. Please help me with this
    The exception I get is as
    Code:
    java.lang.ArrayIndexOutOfBoundsException
    Any help on this is appreciated. Thanks in advance.

  2. #2
    Join Date
    Nov 2009
    Posts
    333

    Re: Segment an image in java

    Hello,
    The exception
    Code:
    java.lang.ArrayIndexOutOfBoundsException
    in your code is related to the following indication. Indicating you use a box that does not exist in your table. If you need more information on the exception which are there in java, then you can visit the sun's official site and their you can find more detailed information on the same and then you can identify that which is the exception you get and what you have to do when you get the exception.

  3. #3
    Join Date
    Dec 2009
    Posts
    192

    Re: Segment an image in java

    Hello,
    Even I get a similar kind of a exception in my program, the error is at the following line:
    Code:
    output [count + +] = labels [w] [h];
    I use an array of 1 dimension output To store the values of "labels"(matrix) and then I go"output"As an argument in
    Code:
    img = createImage (new MemoryImageSource (width, height, output, 0, width));
    to create my image result. So when I try to display the size of each table using.
    Code:
    System.out.println (width);
    System.out.println (height);
    System.out.println (labels.length);
    System.out.println (output.length);
    If you know where I am wrong in then code then please guide me with the correct code. Thanks in advance.

  4. #4
    Join Date
    Dec 2009
    Posts
    211

    Re: Segment an image in java

    Hello,
    This is my updated code, please have a look at it
    Code:
    private int w, h;
     private int[] [] lbl;
     
     private void Growing (BufferedImage image) (
    w = image.getWidth ();
    image.getHeight h = ();
    lbl = new int[w] [h];
    Stack <Point> mustDo = new <Point> Stack ();
        
          for(int h = 0 h <h h + +)
              for(int w = 0, w <w; w + +)
             (lbl [w] [h] = 0;)
    / / to simplify the code I set the seed (seed) to start my choice (x = 5, y = 8)
          int x = 5;
          int y = 8;
          lbl [x] [y] = 1;
          mustDo.add (new Point (x, y));
          while(mustDo.size ()> 0)
               (
               ThisPointer mustDo.get = Point (0); mustDo.remove (0);
               / / Check 8-neighborhood
                for(int th =- 1; th <= 1; th + +)
                  for(int tw =- 1; tw <= 1; tw + +)
                    (
                    int thisPoint.x + rx = tw;
                    int ry = thisPoint.y + th;
                  
                    if ((rx <0) | | (ry <0) | | (ry> = h) | | (rx> = w)) continues;
                    int RGB1 = buffeurActuel.getRGB (rx, ry);
    		        int RGB2 = buffeurActuel.getRGB (thisPoint.x, thisPoint.y);
    			    if (lbl [rx] [ry] <0) (            	    
    			       if (RGB1 == RGB2) (
                       mustDo.add (new Point (rx, ry));
                       lbl [rx] [ry] = 1;
                      
                       )
                    )
                 )
              ) 
        
         int [] opt = new int [w * h];
         int cnt = 0;
         for (int h = 0 h <h = h + +)
        	 for(int w = 0, w <= w; w + +)
        output [cnt + +] = lbl [w] [h];
           
    }

  5. #5
    Join Date
    Nov 2009
    Posts
    335

    Re: Segment an image in java

    Hello,
    I think I have solution for you code and that too it works with me correctly, in your loop, it does not take a <= height but a <height. same for width.
    Here is the code for it
    Code:
    for (int a = 0 a <height a + +)
        	 for(int w = 0, w <width; w + +)
        out [c + +] = labels [w] [a];
    Hope the following will help you.

  6. #6
    Join Date
    Dec 2009
    Posts
    192

    Re: Segment an image in java

    Hello,
    I think the soltuion you have posted works with me. To work on the segmentation of an image by monographic growth area I am about to use BufferedImage when my coach is my intention to convert the image PixelsGraber to facilitate and during my research on the net I noticed the use of PlannerImage with JMF to achieve segmentation by region growing. What is the best choice for good results?

  7. #7
    Join Date
    Apr 2010
    Posts
    2

    Re: Segment an image in java

    cud u please send me the whole code for segmentation... i m in desperate need of it.....
    thnx i advance.....

  8. #8
    Join Date
    Apr 2010
    Posts
    2

    Re: Segment an image in java

    i m a b.tech final year student n i m working on a project for detecting shadow in images which is to b implemented in java.
    for dat, first the image has to b converted in grayscale which i hav done.
    The main problem is dat dis gray image has to b segmented. I dont kn how to do dis in java...
    i an do dat in matlab, but in java i m facing much difficulties.
    I m bound to make dis project in java.

    Cud u please send me full image segmentation code in java at my Email id (vishal.upad008@gmail.com).
    I wud b very thankful to u....

    Thanks & Regards
    Vishal

Similar Threads

  1. How to use Image class in java?
    By Gajananvihari in forum Software Development
    Replies: 4
    Last Post: 27-02-2010, 10:11 AM
  2. Image Display In Java
    By Amaresh in forum Software Development
    Replies: 5
    Last Post: 30-01-2010, 09:20 AM
  3. Mutable Image in Java
    By samualres in forum Software Development
    Replies: 3
    Last Post: 10-12-2009, 01:21 PM
  4. GUI image program java
    By Caden Fernandes in forum Software Development
    Replies: 3
    Last Post: 12-11-2009, 11:48 AM
  5. Mirror image in Java
    By Soft Pack in forum Software Development
    Replies: 1
    Last Post: 18-12-2008, 07:34 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,561,136.85972 seconds with 17 queries