Results 1 to 2 of 2

Thread: region growing method, java code

  1. #1
    Join Date
    Jul 2011
    Posts
    1

    region growing method, java code

    Hi,
    I’m a master student ,
    I’m preparing my master right now,it’s about the images classification.
    I really need “region growing methode” java code.
    Thanks to help me.

  2. #2
    Join Date
    Jan 2006
    Posts
    605

    Re: region growing method, java code

    I normally use the UntiledOpImage subclass, wich should work fine for region growing (I ask for someone confirming: even on tiled images, when computing output image the source will be presented as untiled... the method will present also a comptabile writeable raster:

    Here is a snippet of my code:
    Code:
    Stack pstack = new Stack(); /* Keep track of neightboor pixel */
    Vector visited = new Vector(0); /* Keep track of visited pixel */
    
    /* Getfundamental informations */
    Raster r = source0.getTile(x, y);
    int minX = 0;
    int minY = 0;
    int width = source0.getTileWidth();
    int height = source0.getTileHeight();
    
    /* Compute the resulting image */
    WritableRaster wr = r.createCompatibleWritableRaster(minX, minY, width, height);
    
    /* Set all pixel black XXX Necessary? */
    for (int a = 0; a < height; a++) {
    for (int b = 0; b < width; b++)
    wr.setSample(b + minX, a + minY, 0, 0);
    }
    
    /* Iterate on all origins */
    for (int i = 0; i < origins.length; i++) {
    /* Push origin */
    pstack.push(origins[i]);
    
    while (pstack.empty() == false) {
    Point point = (Point)pstack.pop();
    
    if (visited.contains(point) == false) {
    int value = r.getSample(point.x + minX, point.y + minY, 0);
    
    visited.add(point);
    
    if ((value >= low) && (value <= high)) {
    Point border;
    
    /* Write the current pixel (within intervall) to the destination raster */
    wr.setSample(point.x + minX, point.y + minY, 0, value);
    
    /* Push all border pixel for region growing */
    if (point.x - 1 >= minX) { /* Left border */
    border = new Point(point.x - 1, point.y);
    if (pstack.search(border) == -1)
    pstack.push(border);
    }
    if (point.y - 1 >= minY) { /* Upper border */
    border = new Point(point.x, point.y - 1);
    if (pstack.search(border) == -1)
    pstack.push(border);
    }
    if (point.x + 1 < width) { /* Right border */
    border = new Point(point.x + 1, point.y);
    if (pstack.search(border) == -1)
    pstack.push(border);
    }
    if (point.y + 1 < height) { /* Bottom order */
    border = new Point(point.x, point.y + 1);
    if (pstack.search(border) == -1)
    pstack.push(border);
    }
    }
    }
    }
    }
    
    /* Returns the filtered raster with regions grown */
    return (wr);

Similar Threads

  1. How to change the region code for printer.
    By Limitless in forum Hardware Peripherals
    Replies: 6
    Last Post: 26-11-2011, 05:59 AM
  2. DVD decrypter to remove region code protection
    By Mahendra varma in forum Hardware Peripherals
    Replies: 4
    Last Post: 15-12-2010, 02:20 PM
  3. What is method overriding and method overloading in java
    By beelow in forum Software Development
    Replies: 3
    Last Post: 17-11-2009, 07:20 AM
  4. Java: How can I call one method in another method?
    By biohazard 76 in forum Software Development
    Replies: 3
    Last Post: 16-07-2009, 07:12 PM
  5. Error - region code weird issues
    By dECLANn in forum Media Player
    Replies: 2
    Last Post: 28-01-2009, 12:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •