How to extract edge from a watersheded image?

Juan Nunez-Iglesias jni.soma at gmail.com
Thu Mar 28 09:14:45 EDT 2013


I think the following should work:

# ws is your watershed label mapfrom scipy import ndimage as nd
bound = nd.grey_erosion(ws) != nd.grey_dilation(ws)


The only bad thing about this is that you'll get slightly thick boundaries.
I'm not sure if that's a problem for you.

On Thu, Mar 28, 2013 at 10:37 AM, Zetian Yang <zetian.yang at gmail.com> wrote:

> Thanks Walt,
>
> I need a binary image in which the edges of every labeled region are set
> to 1.
> I've found the `find_boundaries` function in the skimage.segmentation
> module, but its outcome didn't fit my requirement.
>
> Currently, I'm using the following algorithm to solve my question.
>
> ```
> bound = np.zeros(data.shape)
> labels = data.max()
> for label in labels:
>      label_data = data==label
>      bound += label_data - scipy.ndimage.binary_erosion(label_data)
> ```
>
> It seemed work, but I'm not sure its correctness and is there a more
> efficient method?
>
>
> On Thu, Mar 28, 2013 at 12:00 AM, Stéfan van der Walt <stefan at sun.ac.za>wrote:
>
>> Hi Zetian
>>
>> On Wed, Mar 27, 2013 at 5:07 AM, Zetian Yang <zetian.yang at gmail.com>
>> wrote:
>> > I have been trying the watershed algorithm in the skimage package and
>> it is
>> > really fantastic. Recently I have a problem where the edge of one
>> segmented
>> > image is need. Is there a convenient way to extract edges of the
>> watersheded
>> > result?
>>
>> I'm glad you find the package useful!  Do you need the edges as
>> coordinates, or do you need a bitmap of the edges?  We have marching
>> squares for contour finding, edge detection, etc.
>>
>> Stéfan
>>
>> --
>> 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+unsubscribe at googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>  --
> 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+unsubscribe at googlegroups.com.
> 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/20130329/17a0fcfe/attachment.html>


More information about the scikit-image mailing list