Pixel "selection" algorithm

I am trying to write an algorithm that operates on a 2-bit (Black and white) image. Given a black pixel, it needs to be able to find all other black pixels that are directly connected to it, or indirectly connected to it (connected to it by being connected to another pixel that is directly connected to it, however many levels deep). (If you have ever used photoshop before, I am basically refering to the idea of a very simplified magic wand selection tool) I currently have this method implemented recursively, it traverses through the pixels as though they were a tree structure, which works for smaller images, but for larger images (longer paths to traverse) it gets a stack overflow. Does anyone know of any algorithms that would preform this kind of a task?

It is fairly easy to convert a recursive "connected-components" algorithm to an iterative one. You just have to maintain your own stack (Use one of the List implementations in java.util)
Remember that the pathological case for a recursive connected components algorithm results in the depth of recursion equaling the number of pixels in the image.
matfud

Similar Messages

  • Why do I get a "no pixels selected" when making adjustments in a new layer?

    What am I doing wrong?  I want to modify or replace the color in a selection, so I make the selection, create a new layer, and try to replace the color from the Enhance menu.  I get the message " can't do it because no pixels are selected."  The selection is OK; I can see the marching ants.  The same happens when I try other color adjustments and probably other adjustments as well.  Would appreciate some help.  Many thanks.

    Sounds like you have an empty layer selected.
    Even if you have a selection established (showing the marching ants), your creation of a New Layer means that your selection is now on that new layer, which is empty, and thus there are no pixels selected to modify.
    Try skipping the New Layer step.
    Or, duplicate the layer you want to work on, then do the selection, then the adjustment.

  • BGP Best Path Selection Algorithm

    How is the administrative distance positioned in the bgp route decision ?
    i.e If a route is learned from iBGP with higher "local prefernece" and eBGP with lower "local prefernece" - which path will be installed in the routing table
    the path learned from eBGP or the path with higer local prefernce ?

    For your scenario the path with the higher local pref will be installed in the routing table althogh its ibgp.
    if a router recieves the same prefix from 2 neighbors 1 from ibgp and the other from ebgp
    the router will compare them with the bgp path selection algorithm
    the one that wins will be installed in the routing table with the admin distance of the kind of route it is so if the ibgp route won the path selection you will see in the routing table the admin distance of 200,if the ebgp route won you'll see 20 in the admin distance.
    so remember the ibgp/ebgp comparision is the 9th in the path selection algorithm so an ibgp route can win the path selection by (local pref weight....)
    and if the ibgp won then you'll see the ibgp admin dstance in your routing tables.

  • Pixels & Selection Tools

    In Elements 12 I keep getting the dialog "No pixels are selected" or "No pixels are more than 50% selected" when trying to use any of the selection tools and some of the other tools as well. What can I do to correct this problem please?

    Hi, Thanks for your reply, I'm quite new to Photoshop so not too sure about of the technicalities. I've tried it on the background layer, background copy and ordinary layer with the same results, not too sure what you meen by active layer. Regards
    Original message----
    From : [email protected]
    Date : 05/02/2015 - 14:34 (GMTST)
    To : [email protected]
    Subject :  Pixels & Selection Tools
        Pixels & Selection Tools
        created by hatstead in Photoshop Elements - View the full discussion
    Make sure that you are working on an active layer that has information, not a blank layer or an adjustment layer.
    If the reply above answers your question, please take a moment to mark this answer as correct by visiting: https://forums.adobe.com/message/7165146#7165146 and clicking ‘Correct’ below the answer
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page:
    Please note that the Adobe Forums do not accept email attachments. If you want to embed an image in your message please visit the thread in the forum and click the camera icon: https://forums.adobe.com/message/7165146#7165146
    To unsubscribe from this thread, please visit the message page at , click "Following" at the top right, & "Stop Following"
    Start a new discussion in Photoshop Elements by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to https://forums.adobe.com/thread/1516624.

  • Quick Select algorithm - implementation seems not to function- why?

    Hello! I have to work out a essay about the Quick Select algorithm. For this I found a book with implementation code.
    But if I implement it in java it does not work.
    Here is the code, could you please tell me what's wrong with it?
    public class QuickS {
    public static void main(String[] args) {
              int [] int_array = {4,0,6,5,3,9,8,2,1,7};
                    System.out.println("\n"+quickselect(int_array,9,2));
    } //endmethod main
    public static int quickselect (int [] array, int len, int k)
              int pivot = len - 1;
              pivot = partition(array, 0, len -1, pivot);
              int rank = pivot + 1;
              if (k == rank)
              {           for (int m= 0; m < array.length; m++)
                        System.out.print(array[m]+" ");
                   return pivot;
              if (k < rank)
                   return quickselect(array, rank - 1, k);
              else
                   return pivot + 1 + quickselect(partArr(array, pivot+1), len - rank, k - rank);
         }  //endmethod quickselect
         public static int partition(int [] array, int l, int r, int pivot)
          int i = l-1;
          int j = r;
          swap(array, pivot, r);
          pivot = r;
          while(i < j)
               do i++; while ((i < j) && (array[i] < array[pivot]));
               do j--; while ((j > i) && (array[j] > array[pivot]));
               if (i >= j)
                    swap(array, i, pivot);
               else
                    swap(array, i, j);
          } //endwhile
          return i;
       } //endmethod partition
         public static int [] swap(int [] arr, int index1, int index2)
              int tmp = arr[index2];
              arr[index2] = arr[index1];
              arr[index1] = tmp;
              return arr;
         } //endmethod swap
         public static int [] partArr(int [] arr, int index)
              int [] newArr = new int [arr.length-index];
              for (int i = 0, j = index; i < newArr.length; i++, j++)
              newArr[i] = arr[j];
              return newArr;
         } //endmethod partArr
    } //endclass QuickS  Please help me! What do you think is sense of the quickselect method? I thought to find out the index of a searched value? e.g. in this case k=2 and the returned value has to be 2 then. But this doesn't work...

    Oracle9i Database Concepts
    Release 1 (9.0.1)
    Part Number A88856-02
    PL/SQL Blocks and Roles
    The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer rights or invoker rights.
    Named Blocks with Definer Rights
    All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer rights. Roles are not used for privilege checking and you cannot set roles within a definer-rights procedure.
    The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer rights queries SESSION_ROLES, the query does not return any rows.
    Anonymous Blocks with Invoker Rights
    Named PL/SQL blocks that execute with invoker rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker-rights PL/SQL block, and you can use dynamic SQL to set a role in the session.

  • "No Pixels Selected"

    Why do I get the message "no pixels selected"? I make sure the layer I want is unlocked and highlighted. I select all and "inverse" is dark, so I may select it, but when I try I get the message "no pixels selected". I have tried all manner of searches and notes on the internet, but haven't been able to find this issue. I want to inverse the image I have which is black and white photo. I also would like to apply a screen to make it look better. I find the Color Halftone selection, but I don't want a color halftone, I want a black and white one. I have searched using "black & white halftone, photoshop" and haven't found how to do it. I've learned a lot of stuff, but not what I need. I have more questions about RIP, but as that seems to be something the printer does, not the app, I'll put that aside until I figure out "inverse" and halftone. Thanks to any and all who can help me. I'm sure I'm missing a step. (I've done it in the past, I just cannot figure out why I can't do it now.)

    Hi,
    If you just want to inverse the photo (layer), press Ctrl+I (cmd+i) or go to Edit>Adjustments>Invert
    (no selection needed)

  • Suppress Warning, no Pixel selected

    Hello,
    is it able to suppress the Warning - No Pixel selected?
    The warning pops up when I select the lasso tool in subtract from selection mode and I subtract everything. Problem is, since this warning occurs not during a script, I'm not able to use "app.displayDialogs = DialogModes.NO;"
    Is there a way to generaly suppress this warning?
    Thx in advance
    Joerg

    Hello and sorry for my late response, I was busy with other stuff.
    However the problem still exists.
    I'll try to describe what the script does, hopefully you will read this after all this time:
    1. Coworker/-s mark an area with the lasso tool and fill it with a color all on one layer (the area of a painting with a tear for example)
    2. If parts of the tear on the real painting are fixed, coworkers press an action button and the area (tear) in photoshop is selected. (area is surrounded)
    3. Then the lasso-tool is selected in subtract from selection mode and the coworker subtracts the fixed parts of the tear - area
    4. The fixed parts getting deleted from that area
    That all works fine, the only problem is if the whole area is fixed, everything gotta be subtracted from selection and then the warning pops up.
    This is just a very rudimentary description but thats basicly what the script does.
    thx in advance!

  • Preview.app - pixel selection dimensions are back!

    Here's another of Snow Leopard's little unreported fixes.
    I asked a question in the "Using Mac OS X Leopard forum" back in January 2008:
    "In Tiger (OS X 10.4), when I wanted to crop an image in Preview, I would make a rectangular selection by clicking and dragging. If I held down the Option key while doing so, a little window would appear next to my cursor that displayed the pixel dimensions of the selected area. This allowed me to adjust the selection to precisely the size I wanted, which was very useful. However, in Leopard (OS X 10.5), this feature seems to have disappeared. I hold down the Option key but that little selection dimension display doesn't show. Did Preview lose a feature in the Leopard upgrade, or am I doing something wrong?"
    In Snow Leopard, this feature has been reinstated and appears to behave the same as it did in Tiger. Hooray! Thanks for listening, Apple!

    Sounds great -- but is that possible?
    Sure is. I just launched the Tiger Preview, and it is still working in 10.5.2 (and you can still constrain to a square by holding down the Shift key). See the directions in this thread:
    http://discussions.apple.com/thread.jspa?messageID=5889735
    If you have a problem, see my reply near the bottom. I needed to do one more step than the original hint to get it to work for me.
    Francine
    Francine
    Schwieder

  • 'Cut to new layer' function for pixel selection.

    hey guys. This is a pretty minor feature, but it might be handy.
    The feature would be a single comand that could remove pixels from one layer and paste them into a new layer.
    CTL-X technically does this, but since CTL-X clears the selection, the paste has no guide in order paste the pixels into the same location.
    CTL-C, DEL, CTL-V , has the effect of cutting pixels from one layer into a new layer while preserving the selection, but it would be nice to have as a single command.
    The obvious shoice would be CTL-SHIFT-X, but that's liquify, and I like it there.
    So, I propose ALT-SHIFT-X. I know that the alt-shift combination is never ever used, but honestly, it's not a really importnant feature either
    Thanks for reading.

    Already there - control J (new layer via copy) and control Shift J (new layer via cut) - which is exactly what you have asked for. To redload the selection you can simply control click the new layer - mostly you WOULDN'T want to do this, since it just gets in the way. You could reassign them if you wanted.
    Do you seriously think that photoshop version 11- wouldn't have this shortcut by now? These ones were there back in 4 or 5 at least

  • Please describe thread library selection algorithm for Linux JRE (1.4.2)

    Hello:
    While observing strace output I can see certain libraries releated to threading (i.e. /lib/libc, /lib/i686/libc, /lib/tls/libc) being utilized (open or loaded).
    Question: Can someome quantify it wrt the following 'resources'
    1). LD_ASSUME_KERNEL - i.e. does this play any role depending on the value utilized (i.e. 2.2.5 vs 2.4.1)
    2). Older versions of Redhat Linux, where only the original and floating stacks threads are available (i.e. no NPTL)
    i.e. how does the JRE analyze the environment and use the 'intended' resources?
    Question: Also for those of us who may use LD_ASSUME_KERNEL, can you elaborate what the pitfalls are with certain value selections wrt JRE usage (say 2.2.5, 2.4.1, and if available, 2.4.20)
    TIA and Regards

    Hello:
    I am trying to quantify to our customer base what their limitations will be wrt the use of our product which relies on this delivered JRE on various RH Linux versions. To date, I have observed the following:
    1). SIGCHLD is being ignored or trapped on the following Linux hosts:
    All hosts utilizing floating stacks thread, i.e. Linux RH 7.2 - 8.0
    which may be related to
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4785154
    2). Segmentation faults on RH 9.0 and RH Enterprise 2.1 and 3.0 requiring a LD_ASSUME_KERNEL change
    and I suspect that part of the issue(s) here is thread specific.

  • BGP Path Selection

    With reference to cisco's document on BGP Best Path Selection Algorithm (http://www.cisco.com/c/en/us/support/docs/ip/border-gateway-protocol-bgp/13753-25.html).
    Out of given 9 paths why 6th has been selected even though AS_PATH for 8th route is better.
    Can anyone explains here, as this document has not considered the AS-PATH during path selection and used lowest ROUTER ID only.
    Thanks in advance and expect technical explanation here.

    Hey Buddy
    The AS_PATH for both is only 1, don't get confused by (AS_SET) which only counts as 1 no matter how many AS are in the set.  Refer to section "How the Best Path Algorithm Works"
    4.Prefer the path with the shortest AS_PATH.
    Note: Be aware of these items:
    ◦An AS_SET counts as 1, no matter how many ASs are in the set.
    So bearing the above in mind
    Example: BGP Best Path Selection
    Path6
      (64955 65003) 65089 --- this equals 1
        172.16.254.226 (metric 20645) from 10.57.255.11 (10.57.255.11)
          Origin IGP, metric 0, localpref 100, valid, confed-external, best
          Extended Community: RT:1100:1001
          mpls labels in/out nolabel/362
    !--- BGP selects this as the Best Path on comparing
    !--- with all the other routes and selected based on lower router ID.
    Path8
      (65003) 65089 --- this equals 1
        172.16.254.226 (metric 20645) from 172.16.254.234 (172.16.254.234)
          Origin IGP, metric 0, localpref 100, valid, confed-external
          Extended Community: RT:1100:1001
          mpls labels in/out nolabel/362
    Comparing path 6 with path 8:
     Both paths have reachable next hops
     Both paths have a WEIGHT of 0
     Both paths have a LOCAL_PREF of 100
     Both paths are learned
     Both paths have AS_PATH length 1 --- because the (AS_SET) always equals 1
     Both paths are of origin IGP
     Both paths have the same neighbor AS, 65089, so comparing MED.
     Both paths have a MED of 0
     Both paths are confed-external
     Both paths have an IGP metric to the NEXT_HOP of 20645
    Path 6 is better than path 8 because it has a lower Router-ID.
    Hope it helps (:

  • How do I specify exact corners with the rectangular selection tool?

    Suppose I have an image 2000 pixels wide by 1000 pixels high.  Pixel (0,0) is at the top left as you view the image.  Using the rectangular selection tool, how can I specify an exact area to select?  Say, for example, I want to select the area defined by (0,0), (100,0), (100,100) & (0,100), how would I do this?
    I'm using Photoshop CS6 on a Mac with OSX 10.8.3.
    Any help is appreciated.
    Thanks,
    Kevin H.

    Mylenium,
    33,406 posts!  That's amazing.  Thanks for your technique for specifying an exact selection size.  I tried it out and it works, but is there a way to get the marquee to snap to the guides, as opposed to snapping to pixels.  I can't quite get the marquee to fall exactly where I place the guides, at least not easily.
    Here's a method I've come up with since posting my question.  (I guess I should have tried harder to figure this out before asking the question.)
    Figure out beforehand where you want the corners of the selection marquee to be.
    Activate the rulers: View>Rulers or (Cmd-R.)
    Set rulers to pixels: Photoshop>Preferences>Units&Rulers>Rulers>Pixels
    Select the rectangular selection tool.
    In the menu bar for the selection tool choose Style>Fixed Size.  Then in the dimension boxes to the right of the Style button, type in the width and height you want for your selection, e.g. 200 by 100 pixels.
    Zoom in on where you want the top left pixel of your selection to be.  Zoom in enough to clearly see the pixel.
    With the selection tool active, click-and-release on the pixel you have zoomed in on.
    Go back to normal view (Cmd-0) and you should see your entire selection.
    This answers my own question, and with your method I now have two ways to do this.
    Thanks,
    Kevin H.

  • BGP decision algorithm - help needed - stumped

    Hello gurus!  hoping for a BGP expert to chime in here. Im studying for my CCIE, and there is something in Jeff Doyle's Routing TCP/IP vol2 book that I just cant seem to figure out and its really stalling my understanding of the BGP path selection algorithm.  
    Its on pg 195, example 3-57, attached as an image in this post (Ive also attached the network diagram that this output refers to). Basically its an output of "show ip bgp" and whats stumping me is simply: for the aggregate route 192.168.192.0/21, why has this router selected as best (>) the one via next hop 192.168.1.254?? I would have thought based on the presence of the LocalPref = 100 on the 192.168.1.237 route that would have been selected.  But apparently not! Heres a walk through of the path selection logic as i understand it:
    1/WEIGHT: both 0, so skipped. 
    2/LOCAL_PREF: this is my problem, .237 should win, but ignoring for now...
    3/ORIGINATED LOCALLY: neither are they are learnt from BGP peers, so skipping.
    4/AS_PATH: both identical, AS100 only, so skipping
    5/ORIGIN CODE: both are 'i' (IGP), both were created from "aggregate-address" statements on their originating routers downstream in AS100
    6/MED: both empty, so skipping
    7/PREFER [eBGP] over [confedBGP] over iBGP: so the .254 route apparently wins on this condition... which in isolation, i agree with (clearly the eBGP .254 route is better than the .237 iBGP candidate).
    .... however what about step 2/LOCAL_PREF!?  
    looking forward to some expert guidance here to help me squash this one :) 
    thank in advance, 
    Keiran

    Hello,
    Keiran are you talking about "Orgin" attribute or ORIGINATED LOCALLY as this attribute i am not able to find it...that attribute anywhere:
    http://netcerts.net/bgp-path-attributes-and-the-decision-process/
    Path Attributes:
    Attribute
    Class
    ORIGIN
    Well-know mandatory
    AS_PATH
    Well-know mandatory
    NEXT_HOP
    Well-know mandatory
    LOCAL_PREF
    Well-know discretionary
    ATOMIC_AGGREGATE
    Well-know discretionary
    AGGREGATOR
    Optional transitive
    COMMUNITY
    Optional transitive
    MULTI_EXIT_DISC (MED)
    Optional nontransitive
    ORGINATOR_ID
    Optional nontransitive
    ORGINATOR_ID
    Optional nontransitive
    CLUSTER_LIST
    Optional nontransitive
    Also there is similar question on learning forums:
    https://learningnetwork.cisco.com/thread/36845
    From the forum:
    "Locally Originated means that the local router is the one that generated the route with either a network statement, and aggregate statement, redistribution, or conditional route injection.  It's not an attribute that is included in the UPDATE messge, instead it's just used by the local process as part of the path selection, where the router will prefer its own locally originated routes over someone else's origination of the same prefix."
    Hopefully this will help.
    BTW i am reading same book and too bad Mr. Doyle did not include full configs for all routers, as i am trying to simulate his scenarios sometimes it is not working as in his book, now i have issue on next page 197 why Orgin IGP is not taking precedence over Incomplete even if one is learned via EBGP and other over iBGP...driving me nuts.
    Regards,
    Lukasz

  • Inject BGP Default Routes into Multiple VRF before Best Path Selection

    Hello, 
    I have the following setup:
    Multiple Border Routers with eBGP sessions to external AS. We receive a default route from this multiple AS to keep the Table manageable. We noticed an important part of our traffic was been SW routed instead of CEF when we had the Full Internet table. Router Resources came to the ground when we changed to a default. 
    Now I want to separate this default routes into different VRF. Attached is the Diagram. 
    My question is,  the multiple default route all go into the BGP Table. The BGP table then select the best route and place it on the RIB and then to the FIB. 
    I want to redistribute the different Route on the BGP table prior to the Best path selection algorithm and placed on the RIB. 
    How can I achieve this?

    Hi,
    Redistribution of multiple routes to same prefix is not possible. Even if you have configured BGP multipath and all different bgp routes got installed into routing table, during redistribution only route will be redistributed. 
    Also would like to understand the requirement of redistributing multiple BGP routes in to IGP. As per your diagram, 3 different eBGP sessions are on three different routers, so you can prefer eBGP route over iBGP received from other routers and can distribute eBGP route to IGP from each router. Thus you will have three different default routes in to IGP in core.
    Please don't forget to rate this post if it has been helpful
    - Akash

  • Is it possible to lock guides to each other? Or make selections based on guides??

    Hi,
    I am curious if there is a way to lock guides to one another.  By this I mean:  lets say I have a guide at 10px down and another at 20px.  I am looking for a way to lock them, so if I move the first guide down 5px the second guide will move with it and continue to maintain the 10px gap.
    Also I am wondering if there is a way to make selections based on guides.  For example, I want to make a selection that starts at the top guide and goes to the bottom guide.
    Thanks to anyone that can help!
    G

    There is no way to link guides directly. Here are some guide tips for you which may help…
    • Setting the ruler increment can be done by control clicking (yes control) on the rulers themselves,
    • Holding down the SHIFT key while dragging guide lines will snap those guides to ruler increments. So if you have pixels selected as the increment as in the tip above you can easily snap quides to 10 pixel steps. Where the guides will snap (how fine the increment) is dependant on how close you are zoomed.
    • As Christoph has said, you can snap to Guides - so in your example a 10 pixel marquee selection, definable in the marquee tool options bar (fixed size) can easily be snapped to a guide, and then another guide can be snapped to that. With the move tool active this is a very easy process

Maybe you are looking for

  • Oracle Clusterware and Oracle Real Application Clusters Install Guide

    I've downloaded the latest "Oracle Database - Oracle Clusterware and Oracle Real Application Clusters Install Guide - 10g Release 2 (10.2) for HP-UX PA-RISC" (part no. B14202-01) dated August 2005 from OTN. I'm getting the following error when openin

  • PDF embedded in web pages OS 3.0

    I just noticed that now I can't scroll down in PDFs embedded in webpages as I could when I used OS 2.1.1 Back then I just scrolled down with two fingers, now that doesn't seem to work. Someone else with this problem?

  • Puchases apps not syncing correctly on ipad

    I reinstalled the iOS software today on my ipad2 3G and configured as a new device as I did not want any restoration from preVious backups. When I synced my apps, all went in but any purchases that I had done from wi thin the apps did not. As an exam

  • SAP BC 4.8 How to transfer an IDOC to a WebService using a specific WSDL fi

    Hi, I'm not very familiar with the XML, WSDL stuff, but I need to implement a connection between the SAP System and an other software which offers a webservice. I got the WSDL file and now I schould create the Business Connector setup. But I'm not ab

  • Output type configuration

    Hi, I have one doubt. What is the difference between configuring the output type through nace and spro. For few transactions, i see that the functional team add the custom driver program or the form name through NACE and for some cases through SPRO.