Algorithm to 'walk' along a line from an endpoint by N pixels

Robin Wilson r.t.wilson.bak at googlemail.com
Fri Jun 28 12:26:09 EDT 2013


Hi Stefan,

Thanks for the really quick reply. I'm not sure how I can use the label 
function to do what I want. I have the image shown in the numpy array below:

array([[0, 0, 1, 1, 0],
       [0, 0, 1, 0, 0],
       [0, 1, 1, 0, 0],
       [0, X, 0, 0, 0],
       [0, 0, 0, 0, 0]])


I'd like to start at the pixel that is marked with an X (it has a value of 1 really, but I've just marked it in this post as an example), and then find the pixel that is n pixels further down the line than that. So, for example, with n=3 I'd get the pixel marked with E below.


array([[0, 0, 1, 1, 0],
       [0, 0, E, 0, 0],
       [0, 1, 1, 0, 0],
       [0, X, 0, 0, 0],
       [0, 0, 0, 0, 0]])


I can't see how the label function will do that (although it will let me 
extract just the line I want to work on - which will be handy as a first 
step), but I may well be entirely wrong. If the label function won't, is 
there any other function, or group of functions, that would help me do that?

Cheers,

Robin

On Friday, 28 June 2013 17:08:04 UTC+1, Stefan van der Walt wrote:
>
> Hi Robin 
>
> It sounds like you may be able to get away with a connected component 
> search.  Have a look at the "skimage.morphology.label". 
>
> Stéfan 
>
> On Fri, Jun 28, 2013 at 11:04 AM, Robin Wilson 
> <r.t.wil... at googlemail.com <javascript:>> wrote: 
> > Hi, 
> > 
> > Does anyone know if an algorithm to take an endpoint of a binary line in 
> an 
> > image and 'walk' back along the line for N pixels already exists in 
> skimage? 
> > (or in any of the related projects). I'm happy to go ahead and implement 
> it, 
> > but it seems like the kind of thing that would have already been 
> > implemented, even though I can't find it in the documentation. 
> > 
> > Does this already exist? 
> > 
> > Cheers, 
> > 
> > Robin 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "scikit-image" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an 
> > email to scikit-image... at googlegroups.com <javascript:>. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
> > 
> > 
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130628/cffe79ac/attachment.html>


More information about the scikit-image mailing list