How to implement this algorithm with region growing ?

hi,
I would like to ask u to help me in developing code for the region growing segmentation algorithm for digital images.The algorithm perform
1.Model I should use the average of the pixel(for each colorchanel,red-green-blue ) from the color I choose.
2. Strating start by choosing an arbitrary seed pixel via 10X10 region and calculate the average of the region and compare it with neighbouring pixels.
3. growing region is grown from the seed pixel by adding in neighbouring pixels that are similar , increasing the size of the region.
4. stop when the growth of one region stops, then the program should try another direction. the growth is starting on the left and in the same direction as the rotating hands of a clock
the whole process is stoped until the growth of all the direction stoped and choose a largest region with a bounding box. all the pixels in the bounding box is now similar.
I really don't know , how can I do it?
Please suggest the tips to develop or code if u have for this algorithm.
Thanks for ur help

Something you need to consider is what sort of data structure you will use to hold the result of a region that you are growing. One possibility is to keep a second black and white image that is simply a mask of the grown region, i.e. black in the areas that have been included and white in the areas not yet covered.
You also need to determine a threshold for similarity. How close in color space must two pixels be in order that you consider them to belong to the same region. You will need a boolean function that compares two colors and returns true if they are similar.
Finally, if you use a mask bitmap to indicate where you have been, you can proceed in the following sort of manner.
You can sweep across the entire image array, first right to left, then top to bottom, then left to right, then bottom to top, cycling through these 4 directions until nothing changes.
A single sweep will consist of a double nested for loop, one incrementing x and the other incrementing y. Inside the inner loop you are considering a single pixel at (x,y)
So assume that you are sweeping from left to right, i.e. incrementing x
You will be expanding the reagion at (x,y) only if
a) mask(x-1,y) is black (i.e. the previous pixel is in the region.
b) maks(x,y) is white (the current point is not in the region
c) color of image at (x,y) is similar to color of region
When you update the region you will
a) color the mask at (x,y) black
b) add the RGB from the image to TotalR,TotalG,TotalB in region
c) increase point count for the region
The point count for a region and the TotalR etc allow you to compute the average color of the region at any time. You can detect if a single pass changed anything by noticing if the pointCount changed between two passes
This algorithm is not particularly efficient, because you keep sweeping over the entire array, but it is easy to comprehend and easy to code.
Note: the hard part is determining a decent threshold for color similarity. everything else is very straight forward.
Enjoy!

Similar Messages

  • How to implement this algorithm ?

    Hello all,
    can u help me in implementing the following algorithm in java?
    1.suppose we start with a single pixel p and wish to expand from that seed pixel to fill a coherent region. lets define a similarity measure s(i,j) such that it produces a high result if pixels i and j are similar and a low one otherwise.
    first, consider a pixel q adjacent to pixel p. we can add pixel q to pixel p's region if S(p,q)>T for some threshold T. we can the proceed to the othr neighbors of p and do likewise.The process will continue till all the pixels in the image are labelled or belong to one region or the other.

    You may want to look at the various Connected components algorithms out
    there. These (tend to) recursively search the neighbours of the seed
    pixel and check for similarity. If the neighbours are similar to the
    seed they are marked as being in the same region. These algorithms can in general be made to run using a stack and while loop rather then using recursion (which on large images can get you into memory trouble very rapidly).
    A basic algorithm does the following
    create a second image containing ints. This image is the output from the algorithm. different regions have different integer numbers assigned to them. Ensure all pixels have -1 as their value.
    from your seed pixel check each of its neighbours in turn
    // the output image of integers
    private Image output;
    // the input image to process
    private Image input;
    // origin of the image is in the top left
    // assuming input image is greyscale and getPixel() / setPixel()
    // return Pixel objects. regionvalue should be greater then 0
    public void processPixel(int x, int y, Pixel compareTo, int regionValue)
       // am I similar to the pixel passed in
       // if so set my corresponding pixel in the output image
       if(isSimilar(input.getPixel(x,y),compareTo))
          output.getPixel(x,y).setGreyValue(regionValue);
       } else
          // i am not similar so bail out at let the caller check its
          // other neighbours
          return;
       //check north
       if( output.getPixel(x,y-1).greyValue() == -1)  // -1 means that its not been processed
          // this compares new pixel to this pixel
          processPixel(x,y-1,input.getPixel(x,y), regionValue);
       //check north east
      if( output.getPixel(x+1,y-1).greyValue() == -1)  // -1 means that its not been processed
          // this compares new pixel to the seed pixel
          // achives a different goal then the search for north given above
          // choose which goal suits you best
          processPixel(x+!,y-1,compareTo, regionValue);
       // check east
       //check south east
        //check north west
    // nope you are not mistaken all 8 neighbours may need to be checked if
    //  processing a greyscale image.
        return;
    }matfud

  • Webinar: How to implement secure scenarios with SAP NW PI 7.1

    SAP Intelligence Platform & NetWeaver RIG APJ Expert Call
    Dear valued SAP Experts,
    Next SAP Intelligence Platform & NetWeaver RIG Expert Call Session will take place on Tuesday, August 18.
    The SAP Intelligence Platform & NetWeaver RIG Expert Call Sessions are designed to support consultants, partners and customers  during their implementation projects. The sessions cover all different aspects of SAP NetWeaver and are aimed at
    thus provide knowledge which is not available via standard training courses. The session duration is typically 60min and includes questions and answers.
    Tuesday, August 18, 2009:
    How to implement secure scenarios with SAP NetWeaver Process Integration 7.1
    Time: 2.00 - 3.00 p.m. Singapore Time (UTC +8)
    This event will feature Makoto Sugishita with the SAP Intelligence Platform & NetWeaver Regional Implementation Group.
    Makoto provides the following abstract:
    In this session you will learn more about the core security concepts that are provided with the service-oriented architecture (SOA)
    management capabilities in SAP NetWeaver Process Integration (SAP NetWeaver PI). This session will cover main use cases and
    supported scenarios of secure SAP NetWeaver PI deployments. 
    SAP Connect Link: https://sap.emea.pgiconnect.com/I016095
    (no passcode needed)
    Dial in:
    For dial in details please register here http://www.surveymonkey.com/s.aspx?sm=EFeuZl9PxrwKOW5i5W556g_3d_3d
    Kind regards,
    Sarma Sishta
    SAP Intelligence Platform & NetWeaver RIG APJ

    hi,
    I'm making this a sticky thread till August 18 so it will have better visibility
    Regards,
    Michal Krawczyk

  • How to implement this in Oracle Apps 11i

    Hello Friends
    I am working as a consultant for a manufacturing company.
    They have a format for charging Excise and Sales tax on their products (example below). I dont know how to implement this using oracle apps. Please help me ASAP.
    eg.
    Product A:
    MRP = Rs. 100
    Assessable Value (i.e. the value at which I have contract with the Government to pay Excise Duty) = 60% of MRP = Rs. 60 in this case.
    Excise Duty = 16% of AV =0.16*60 = Rs. 9.6
    Now, let’s suppose I am selling my product to a dealer at 30% discount.
    Therefore, Sale Price = 70% of MRP = Rs. 70
    Sales Tax = 4% of Sale Price = 0.04*70 = 2.8
    Therefore, total revenue from the deal = 70-9.6-2.8 = Rs. 57.6

    you can use Advance Pricing or creating discount or attiribute while calculating.
    this is not much complex, possible even with Advance Pricing too. Thanks
    Shiv

  • How to implement this code in labview?

    How do implement this pseudo code in labview? Please keep in mind "a" and "c" in the code below ARE VARIABLES
    for i =0 to i=maxvalue
           if i <= a 
               output = output2
           else if i > a AND i<=c
               output = output2
           else if i < c 
               output = output3
           else i = d
               output = output4
    I understance i can use a case structures and modify the label, but i do not know how to make the label dependent on a variable value. 
    Thanks 

    Try an array of boudaries and use threshold array. See this old example:
    Now just iterate over an array of values using a FOR loop.
    LabVIEW Champion . Do more with less code and in less time .

  • How to implement this attribute ?

    Hi,
    I've this problem.
    In our application to control healthcare expense I've implemented a cube with 6 dimensions. (here for who knows Italian : http://www.oracle.com/global/it/customers/profiles/profile_77.html )
    The biggest dimension is the "patient" one, with 1.500.000 units at 5th level, grouped in geographic aggregates, until the entire city at highest level.
    Now customers wants to have the possibility to select patiens with chronic disease from these. There are about 500 kinds of chronic diseases.
    Every patient can have no one, one, or (and this is the problem) more then one of these chronic disease.
    How to try to implement this? as a new dimensions or as an attribute ?
    I've thought that best way is to introduce a new (chronic diseases) dimension, to have a way to select one or more of these diseases at all levels of patient dimension.
    I'm asking how to solve the problem that a single patien can also have more than one disease.
    Is there any way to implement this ?

    thanks to everyone for the answers
    I've some questions.
    to olapworld:
    have you any sample code to show me how to implement the dimensionalized valueset and the customizations needed ??
    to scott:
    I think I'm not understanding your suggestion:
    my target is to add the "ilnesses" selection to other ones. The most important cube of my applications analyze
    healthcare expenses from six dimensions. Customer wants analyze cube "adding" a way to select only "ilnesses" patients and elvaluate their expense.
    I'm in doubt becouse a patient can also have more then one ilness, so I can't simply add a "ilnesses" dimensions to the cube and mapping it to an "ilness_id" in the fact table.
    How can the two dimensioned cube to help me in this ?
    to Rafalm1:
    in any case, implementing Count(Distinct patient) would be useful for me, to have a way to count the number of patients who had a healthcae assistence. Can you suggest me how to implement this ?

  • How to implement this functionality?

    hi,
    I want to use a thread to send all message centrally. The thread will check if the internal queue is empty. If the queue isn't empty, it sends the message, otherwise, it yields. The code snippet is as the following.
      public void run()
        logger.info("Sending thread started.");
        try{
          while (isConnected) {
            if (!bufferQueue.isEmpty() && !isReconnecting) {
              sendMsgInternal();
            } // bufferQueue.isEmpty()
            else {
              Thread.yield();
        catch (Exception e)
          logger.error("Fatal exception in sending thread", e);
          isConnected = false;
        finally
          sendThread = null;
      }This method works fine. But I found the CPU occupying rate is always 100%.
    Can somebody give me the better method to implement this logic with lower CPU occupying rate??
    Thanks in advance!
    Regards,
    Jason

    I think i have gotten the solution. It shouldn't use yield() method. It waste so much CPU time.
    I think the solution is using wait() and notify() in pair. The snippet code is as the following:
       public final synchronized void send(Object m) {
          if (m == null) {
             System.err.println("null message passed to send()");
             throw new NullPointerException();
          numMessages++;
          messages.addElement(m); // at end
          if (numMessages <= 0) notify();
       public final synchronized Object receive() {
          Object receivedMessage = null;
          numMessages--;
          if (numMessages < 0) {
             while (true) {     // we must be notified not interrupted
                try {
                   wait();
                   break;       // notify(), so get message
                catch (InterruptedException e) {
                   System.err.println
                      ("receive(): InterruptedException, wait again");
                   // race condition fix, see Semaphore.java
                   if (numMessages >= 0) break;
                   else continue;    // no message yet
          receivedMessage = messages.firstElement();
          messages.removeElementAt(0);
          return receivedMessage;
       public void run()
         logger.info("Sending thread started.");
         try{
           while (isConnected) {
               sendMsgInternal(receive());
         catch (Exception e)
           logger.error("Fatal exception in sending thread", e);
           isConnected = false;
         finally
         { // Set to null, avoid restarting the thread.
           sendThread = null;
       }For the details of this method, please refer to the following link:
    http://www.cs.drexel.edu/~shartley/ConcProgJava/messaging.html
    If there are some drawbacks, please let me know.
    Regards,
    Jason

  • How to implement this aggregate logic at target column in odi inteface mapp

    sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
    how to implement this aggregate logic at target column in odi inteface mappings

    Hi
    if you don't want to aggregate try to define a user function
    analytic_sum($(value))
    implémented by
    sum($(value))
    after that
    replace your
    sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)
    by
    analytic_sum(NOTICES) over ( partition by property order by RELAVANTDATE range between interval '30' day preceding and current row)

  • How to make this work with Firefox, HELP!

    Downloading for Real-player, after watching the full movie, I click download and it has to reread the movie from the internet. When using explorer, after downloading the movie, it reads it from memory, which makes it a fast download. How to make this work with Firefox, I like not to use Microsoft products, and I really like Firefox 7.0.1!!!! HELP!

    -> click '''Firefox''' button and click '''Options''' (OR File Menu -> Options)
    * Advanced panel -> Network tab
    * place Checkmark on '''Override Automatic Cache Management''' -> under '''Limit Cache''' specify a large size of space
    * Remove Checkmark from '''Tell me when websites asks to store data for offline use'''
    * click OK on Options window
    * Restart Firefox
    Check and tell if ts working.

  • How to set this filters with 'or' relationship

    Hi Pros,
          I have a query as follows, rows and columns are all in structures.
                                                       regular_employees
                 active_employees
                 lay_off_employees
         I want to set up filter as ' employ_status = 0 or employ_subgroup =2' for this query, please tell me how to set this filters with 'or' relationship.

    Hi Yifei,
    Create a formula and enter this (let's name this FORMULA_KF):
    ((EMPLOY_STATUS = 0) OR (EMPLOY_SUBGROUP = 2)) * enter value IF_TRUE + enter value IF_FALSE
    Then create the condition to HIDE the rows having those values to be filtered (if this is your purpose)..
    Like,
    FORMULA_KF <> 1
    Is this what you want mate?
    Regards,
    Loed

  • How to converse this algorithm!!!please help me!!!

    protected static final int getHash(byte [] data)
    int off = 0;
    int len = data.lenght;
    int k = 147;
    try{
    for(int l = off + len; l > off;)
    k = k * 147 ^ data[--l];
    return k;
    catch(Throwable throwable){
    return k;
    If I have the result of thie method like as: 0x69a6d9dd, how I converse this algorithm to get the original data.(the passed paramether)
    the data's length is no more than 3!!!!

    Post Author: pvierheilig
    CA Forum: Crystal Reports
    Put this in the Color tab formula for the Details section in the Section Editor: If (RecordNumber mod 2) <> 0 Then crSilverelse DefaultAttribute

  • Technology P2P with JAVA (How can i do for implement this tech with JAVA B)

    Thanks for read this message,,, I will glad with you if you can help me...
    I would like desing, make, build, a point to point aplication with JAVA Builder, I have been reading about sockets but its not enought,,,,,,
    can you help me????
    Thanks

    Well , thanxs for take attention,,,
    I need some information about Point to Point tech because I would like to make an aplication with JAVA Builder...
    First step is to know how works the point to point...could you give me some links?
    Second step is to know how can I do for implement this tech?
    Third step is to know Is Java Builder the most indicate languaje for this aplication?
    Fourth step is - if Java Buider is the indicate tool, What have to know for make the aplication?
    Well,,I dont speak english very well but is the best that i can do?
    BYE

  • How to implement this function in JSP/Servlet env?

    Hi all,
    I working on a project, it provides functionality to upload file using JSP/Servlet. In the first JSP page, there is file location and submit button. After user select a file to upload and click submit button, a message, like "sending file to XXXX", will be shown on the screen. Once uploading and validation are done on the server-side, a successful/error msg will be shown to user.
    Here I have a question for the "sending..." msg and the successful/error msg. They should be put in one jsp page or in two separate page? how to implement them?
    Thanks for any help!
    Tranquil

    For the sending message... Well, the thing is, when you click submit, it's sending the file to the server and the server is processing it, and this is all done before the "complete" page is sent to the server. So one would need to use some Javascript on the page before the actual submit happens to show some message. This is done on Ebay when you put something for sale, you can upload an image, and there is a little popup message telling you that it's uploading, and it is removed when the process is done. Now, I'm not sure the exact details of how this works, but my educated guess is this:
    1) The onsubmit function of the form checks that the file upload fields have a value (no need to popup a message if no file upload, since that's what usually takes the time, although it could just be assumed there is a file). If a file is to be uploaded, or just want to show the message anyway, a new popup window is opened with the window.open method and the "sending" message is shown (either written via Javascript or just load a small web page to the window).
    2) The popup window, since you can't transfer the window object from the form page to the next page, has to check window.opener for some value that the success/error page would have to set. The success/error page could use it's body onload function to set a variable in it's own window object to denote that the page is loaded. The popup window can use a looping check using setTimeout or setInterval in Javascript to check for window.opener.isLoadedVariable to be present, and if so, close itself.
    I've never done that, but I see no reason why it wouldn't work.

  • How to implement this Form page in ApEx

    Hi,
    I'm using ApEx 4.0.1 with Oracle 10g r2.
    We have an old form (built with Forms 10g) that we want to implement with ApEx.
    Data are shown using some items and I can't find how to do the same with ApEx. It is quite hard to explain so here is a screenshot (png) : http://bailly.yann.free.fr/autres/OTNForums/form_mesures_offsets.png
    Buttons with arrows allow user to navigate through the records. A PL/SQL program is currently used to fetch rows.
    So it seems I can't use a report because I can't fetch all rows with a single query.
    And I don't want to use modifiable items (textfields, textarea, ...) like in that form but simply show all data.
    Any idea on how I can achieve this ?
    Thanks!
    Yann.

    So it looked to me like a single form tied to a custom query to retrieve the data will be sufficient. I would start with about 5 items including your key id. Then create a custom procedure that fires BEFORE HEADER like this:
    declare
    begin
      select COL1, COL2, COL3, COL4
        into :PX_VAR1, :PX_VAR2, :PX_VAR3, :PX_VAR4
        from MY_TABLE
       where KEY_ID = :PX_KEY;
    end;You can make the SQL retrieval as complicated as you need. You will have to determine how to populate the Key field, whether that is by passing in a variable from another page or using another process to get it. Once you have a few items working, start creating the rest of your page items and add them to the query procedure.
    If you need to change any of them, you can create a second procedure that saves the information back to the DB:
    declare
    begin
      UPDATE MY_TABLE set COL1 = :PX_VAR1, COL2 = :PX_VAR2, COL3 = :PX_VAR3, COL4 = :PX_VAR4
       where KEY_ID = :PX_KEY;
    end;

  • How to implement this typical sign workflow? Urgent

    Hi Adobe Experts,
    I am new to LC (two months only). Recently company is doing some evaluation on LC 8.2 and my boss assigned the following task to me  (I simplified it):
    Form: (Enclosed)
    * Two text fields: CommentTextField1 and CommentTextField2
    * Two signature fields: SignatureField1 and SignatureField2
    I've associated the SignatureField1 to lock CommentTextField1 and associated the SignatureField2 to lock CommentTextField2.
    The progress to implement is:
    Step 1) Ray Woodard open the form in workspace, type in CommentTextField1, Sign the SignatureField1, Submit.
    Step 2) Alex Pink open the form in workspace, type in CommentTextField2, Sign the SignatureField2, Submit.
    Any suggestions on how to implement the progress? Please help! Thanks a lot!
    (What I am able to accomplish so far is the step 1, but I am not confident about that. Please point me the right solution. Should I use xfaForm or Document Form, render/submit as default or PDF, submit as XDP or PDF etc...? I am so confused and frustrated now!)

    Steve, thank you so much!!!
    Your example helped me a lot. I am able to run the process, but I still have three doubts:
    1) When I set "Submit As" to "PDF" rather than "XDP" by default, I am not able to submit the form in the workspace client with "Adobe Reader" installed. But I am able to submit the form in the workspace client with "Adobe Acrobat" installed. Is it normal?
    2) What does "Form Bridge" do in this whole process here?
    3) If I don't want to hard code the submit URL  in the form, do I have another option, like using other renders?
    Thanks again!
    Wayne

Maybe you are looking for