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

Similar Messages

  • 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!

  • 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 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 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

  • How to implement this calendar function in ABAP code

    Hi everyone,
    Our requirement is : Give a date (e.g. YYYY.MM.DD, 1983.12.26), then we need to know which weekday it is. Is there a existing FM for this fuction? or how to implement it in ABAP?
    Thanks a lot for any hint
    Best regards
    Deyang

    Hi Deyang Liu,
        Could you please check these the below links they would give you some idea ....[SAP Calendar Control|http://help.sap.com/printdocu/core/print46b/en/data/en/pdf/BCCICALENDAR/SAP_KALENDER.pdf]
    [Calendar functions |http://help.sap.com/saphelp_nw04/Helpdata/EN/2a/fa00f6493111d182b70000e829fbfe/content.htm]
    [SAP Functions|http://abap4.tripod.com/SAP_Functions.html]
    [Determine calendar |http://help.sap.com/saphelp_nw04/helpdata/en/2a/fa00e9493111d182b70000e829fbfe/content.htm]
    Regards,
    S.Manu

  • How to implement this logic in odi

    suposse my table is like this
    a b c
    1234 01-JAN-09 0
    1234 02-JAN-09 1
    1234 05-JAN-09 1
    1244 06-JAN-09 1
    1234 10-JAN-09 0
    1234 13-JAN-09 1
    1234 25-JAN-09 0
    1234 27-JAN-09 1
    1234 30-JAN-09 1
    1235 01-JAN-09 1
    1235 02-JAN-09 0
    1235 05-JAN-09 1
    1245 06-JAN-09 1
    1235 10-JAN-09 1
    1235 13-JAN-09 3
    1235 25-JAN-09 2
    1235 27-JAN-09 0
    1235 30-JAN-09 0
    i want out put like this
    a b c
    1234 01-JAN-09 0
    1234 02-JAN-09 1
    1234 05-JAN-09 2
    1244 06-JAN-09 3
    1234 10-JAN-09 3
    1234 13-JAN-09 4
    1234 25-JAN-09 4
    1234 27-JAN-09 5
    1234 30-JAN-09 6
    1235 01-JAN-09 1
    1235 02-JAN-09 1
    1235 05-JAN-09 2
    1245 06-JAN-09 3
    1235 10-JAN-09 4
    1235 13-JAN-09 7
    1235 25-JAN-09 9
    1235 27-JAN-09 9
    1235 30-JAN-09 9
    to get out put like that iam using this query
    select a,b,sum(c) over(partition by a order by b) from table.
    how to implement "sum(c) over(partition by a order by b)" in odi interface 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 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 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

  • How to implement this need help

    I created a datacontrol for a named query which (using Ejb entity beans) which accepted a employee id and click on find show me the respected employee details in a table.
    case 1: In one single page
    when i added the form consisting of a single text box , button and the table to show the result of the find method in one single page it worked out perfectly,,,
    case 2 : using 2 different pages
    But then i tried adding only the form in one page named page1 and and the table to show the result in another page i.e page2 , Also in the command action of find button of page1 i asked it to redirect to page 2 and show result . But it never showed me any results..
    Question :
    1) How to implement case2 i.e to have a form on one page and the resultant table to be show on another page i.e When users sees first page he adds the employee id in text box and clicks find .The user then needs to be redirected to page2 and the result of search should be shown in table...
    Can anyone guide me over this... ???

    Hi,
    you use a method on the EJB that takes a argument (e.g. the employee ID). You then put the method result set on page 2 (the method argument shall be pointed to a request or session attribute using EL : #{sessionScope.EmployeeId}
    On the search page - when the user hits the search button - you set the attribute "EmployeeId" in the session before navigating to the next page
    Frank

  • How to implement this Java Script?

    Hello,
    I have this script to remove the link from titles of web parts.  I am new to SharePoint 2013 development. I am not sure where to put it. Not sure what file to put it and how to implement it.  How can ensure this code gets run on pages through out
    my SharePoint 2013 site.
    jQuery(document).ready(function () {
           $('a').filter("[href='###']").each(function () {
            $(this).replaceWith($(this).html());
    Reference
    https://expectedexception.wordpress.com/2012/01/30/how-to-remove-the-list-view-web-part-title-bar-link/
    Paul

    Get the page Url from the website and go to Sharepoint Designer and browse the page and add the script within a scritp tag <script>jQuery(document).ready(function
           $('a').filter("[href='###']").each(function () {
            $(this).replaceWith($(this).html());
     });</script>
    how to open a site in SP Designer:
    https://support.office.com/en-ie/article/Open-a-SharePoint-site-94d33d70-3f07-4a8e-b5b5-1137a9c36e74
    another option is to find the global file that contain the scripts and add it as a method there. You can check these files by viewing source of the page.
    note also that the Jquery reference is needed for this code to execute.
    Fouad Roumieh

  • How to implement this? please help

    In my java class, I have a string array called strarray which hold serveral elements, some of the elements have the same value , for example, the first element is "swimming", the forth element is also swimming. I use a for loop to get each element and give it to arrayHolder which is also a array with the same size as strarray. Now, what I want is: I defined a Vector called element I want this vector to filter out the element from arrayHolder, get the name of non-duplicated name from the arrayHolder, the result should be inside the element vector (swimming,walking,running,dancing), no duplicated name. My code is like follows:
    import java.util.*;
    import java.io.*;
    public class arrayTest{
    public static void main(String arg[]){
    String[] strarray={"swimming","running","walking","swimming","dancing","running"};
    String[] arrayHolder=new String[strarray.size];
    Vector element=new Vector();
    for(int i=0;i<strarray.length();i++){
    arrayHolder[  i  ]=strarray[  i  ];
    /* What should I do next to get the non-duplicated element from arrayHolder and
    * add them into the element vector????
    I did not finnish it, since I am a little bit confused, how to implement? Need some help. thanks.
    Message was edited by:
    Mellon

    Not sure if I see the use of strArray & arrayHolder (I've not looked at your code - you might use code tags next time (check the "code" button above the message textarea), but may I suggest using a Map of some sort instead of a Vector? It will prevent duplicates for you.
    Good Luck
    lee

  • How to implement this in Smartforms

    Hello,
    I have been given this information for what is wanted in a proforma invoice:
    Print a field for bankcode. Field name = tempBANKL.
    Logic:
    Select BANKS BANKL into tempBANKS tempBANKL from T012
    where BUKRS = ls_bil_invoice-HD_ORG-COMP_CODE and HBKID = tempHBKID.
    What do I need of nodes in my window in order to implement this ?
    Thanks in advance.

    Hi
    In the program line node just before the Text node where you need to print the Bank  code, pass ls_bil_invoice-HD_ORG-COMP_CODE  and tempHBKID as Inputs/Import and tempBANKS and tempBANKL as ouput/Export
    In this program line node, you can have your select statement. And, the text node below, will have &tempBANKL& as content.
    Regards
    Raj

Maybe you are looking for

  • Problem with Open document SSO using websphere.

    Hi All, I have a issue, We configured AD SSO using websphere and its working fine but when we try to login to the open document SSO using websphere it prompting for login credentials. Is there any steps needed for configure open document SSO using we

  • Views in MDM

    Dear MDM Experts, 1. how can I define views for user groups in MDM? As I saw usage of masks are not too good for this, because when new items come into the repository, the Catalog Manager should everytime renew the masks. Am I right? Can I define din

  • How to implement a service that runs once a day?

    Hi all, is there a service or so available that waits for example 24 hours and runs every day for example at 9:00 am? I know there is the Wait service with the scheduleWait operation, but I can only specify days, hours or minutes. So I can not use th

  • Delayed connection to internet after joining wireless network

    This is a strange one. I have an Extreme-N (Gigabit) connected to my DSL modem and distributing IP addresses via DHCP, and an earlier Extreme-N (100base-T) conncted via WDS. Using 5Ghz wide channels, WPA encryption. Firmware 7.2.1. Until the pasty fe

  • Unable to create Aggregate Level on Multi Provider ( Real and Standard)

    Hi all ,    I am not able to create a " Aggregate Level " on a Multi Provider. When i say create i can't see any info Objects for selections and everything is grayed out i can't select the check boxes . Any idea on what i am doing wrong ? Is this an