Get border pixels of labelled region

Juan Nunez-Iglesias jni.soma at gmail.com
Thu Sep 5 02:49:40 EDT 2013


Hi Payal,

I think you're misunderstanding the purpose of "find_boundaries"... Not
quite your fault since the documentation is pretty sparse there.

I'll use my favourite fuzzball as an example:

[image: Inline image 1]

"find_boundaries" is meant to take in a segmentation, which is an image in
which each region has a different integer label, like this one:

[image: Inline image 2]

Then, find_boundaries merely looks for pixels where the neighbouring labels
are different:

[image: Inline image 3]

It's not doing any edge detection per se, it's just a tool for displaying
segmentations when it is easier to look at edges than at regions (above). I
think what you are after is edge detection? Maybe an image like this one:

[image: Inline image 4]
?

For that, you should directly use the edge detection algorithms, such as
Sobel or Canny, without previously thresholding your image. Have a close
look at the examples gallery to figure out if any are close to what you are
after, and try to apply the code there to your own image:

http://scikit-image.org/docs/dev/auto_examples/

Some of the more pertinent ones, I think:
http://scikit-image.org/docs/dev/auto_examples/plot_canny.html
http://scikit-image.org/docs/dev/auto_examples/plot_edge_filter.html
http://scikit-image.org/docs/dev/auto_examples/plot_join_segmentations.html
http://scikit-image.org/docs/dev/auto_examples/plot_label.html
http://scikit-image.org/docs/dev/auto_examples/plot_marked_watershed.html
http://scikit-image.org/docs/dev/auto_examples/plot_random_walker_segmentation.html
http://scikit-image.org/docs/dev/auto_examples/plot_watershed.html
http://scikit-image.org/docs/dev/auto_examples/applications/plot_coins_segmentation.html

Note that in the edge detection examples, Canny/Sobel is applied to the
image *before* any thresholding — unlike the example code you provided.

Juan.


On Wed, Sep 4, 2013 at 5:31 PM, Payal Gupta <erpayal2010 at gmail.com> wrote:

> hello everyone...
> i will try this code,in this  i want to do read a image then do edge
> detection after that find the boundaries of image object. but
> find_boundaries return me a bool array but i need a integer array. is it
> any solution of this.
>
>
> code::
>
> import Image
>
> from skimage import segmentation as seg,io,filter
>
> imge = io.imread("IMG_1.jpg")
>
>  thresh = filter.threshold_otsu(imge)
>
> binary = imge> thresh
>
> edge_canny = filter.canny(binary)
>
> bimg =seg.find_boundaries(binary)
>
> print(bimg)
>
> fig, (ax0, ax1) = plt.subplots(ncols=2)
>
> ax0.imshow(bimg,cmap=plt.cm.gray)
> ax1.imshow(binary,cmap=plt.cm.gray)
>
>
> On Tue, Sep 3, 2013 at 7:42 PM, Stéfan van der Walt <stefan at sun.ac.za>wrote:
>
>>
>> On 3 Sep 2013 11:45, "Payal Gupta" <erpayal2010 at gmail.com> wrote:
>> >
>> > thanks it working but i confused when i use function of skimage
>> library. i want to change rgb image to a graylevel image but inbuilt
>> function rgb2gray not convert gray level image.
>> > reply.
>>
>> If you want help on this list, please provide code examples of what you
>> are attempting.
>>
>> Stéfan
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "scikit-image" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/scikit-image/rXRS0KT2PdU/unsubscribe.
>> To unsubscribe from this group and all of its topics, 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/20130905/b443d11b/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: boundary_im.png
Type: image/png
Size: 3072 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130905/b443d11b/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: label_im.png
Type: image/png
Size: 2610 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130905/b443d11b/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Screen Shot 2013-09-05 at 4.09.48 PM.png
Type: image/png
Size: 507844 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130905/b443d11b/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 159022.jpg
Type: image/jpeg
Size: 19541 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20130905/b443d11b/attachment.jpg>


More information about the scikit-image mailing list