label_boundaries problem with ndim = label_img.ndim

Juan Nunez-Iglesias jni.soma at gmail.com
Wed Dec 2 02:59:53 EST 2015


You don't need to find the boundaries manually before calling
mark_boundaries. From the docstring of mark_boundaries:


Parameters
----------
image : (M, N[, 3]) array
    Grayscale or RGB image.
label_img : (M, N) array of int
    Label array where regions are marked by different integer values.

Currently, you are passing a boolean array to a function that expects an
integer array, which is why it's failing.

In general, it's a good idea to try typing "help(function_name)" when
things are failing to make sure that you are passing in the right
information to the function you're using! (You can then press "q" to exit
help.)

I hope that, erm, helps! =)

Juan.

On Wed, Dec 2, 2015 at 6:46 PM, Eyal Saiet <ejsaiet at alaska.edu> wrote:

> thanks Juan, I have tried that too:
>
>    1. label_image=measure.label(g_median_bin, background=0)
>    2. label_image +=1
>    3. plt.figure()
>    4. plt.imshow(label_image,cmap=plt.cm.gray,interpolation='nearest',
>    origin='lower')
>    5. plt.title('label_image')
>    6. plt.show()
>    7. props=measure.regionprops(label_image,intensity_image=g_median_bin)
>    8. label_bound=segmentation.find_boundaries(label_image,connectivity=1,
>    mode='thick',background=0)
>    9. boundaries=segmentation.mark_boundaries(g_median,label_bound)
>
> Traceback (most recent call last):
>   File attributes_thrash.py", line 127, in <module>
>
> boundaries=segmentation.mark_boundaries(g_median,label_bound)#,color=(1,0,0),
> outline_color=None, mode='outer', background_label=0)
>   File
> "/usr/local/lib/python3.4/dist-packages/skimage/segmentation/boundaries.py",
> line 213, in mark_boundaries
>     background=background_label)
>   File
> "/usr/local/lib/python3.4/dist-packages/skimage/segmentation/boundaries.py",
> line 156, in find_boundaries
>     max_label = np.iinfo(label_img.dtype).max
>   File "/usr/local/lib/python3.4/dist-packages/numpy/core/getlimits.py",
> line 254, in __init__
>     raise ValueError("Invalid integer data type.")
> ValueError: Invalid integer data type.
>
> Process finished with exit code 1
>
>
> On Tue, Dec 1, 2015 at 10:38 PM, Juan Nunez-Iglesias <jni.soma at gmail.com>
> wrote:
>
>> Hi Eyal,
>>
>> You are passing a list of regionprops (props, in your code) to
>> "find_boundaries", whereas it expects an array: a single image of labeled
>> objects (label_img, in your code).
>>
>> Juan.
>>
>> On Wed, Dec 2, 2015 at 5:33 PM, Eyal Saiet <ejsaiet at alaska.edu> wrote:
>>
>>> Stefan,
>>> I do not understand what is not true about the label_image object.
>>> bellow is the code, in addition I added a plot of the label_image object.
>>>
>>>
>>>
>>>    1. label_image=measure.label(g_median_bin, background=0)
>>>    2. label_image +=1
>>>    3. plt.figure()
>>>    4. plt.imshow(label_image,cmap=plt.cm.gray,interpolation='nearest',
>>>    origin='lower')
>>>    5. plt.title('label_image')
>>>    6. plt.show()
>>>    7. props = measure.regionprops(label_image,intensity_image
>>>    =g_median_bin)
>>>    8. label_bound=segmentation.find_boundaries(props,connectivity=1,mode
>>>    ='thick',background=0)
>>>    9. boundaries=segmentation.mark_boundaries(g_median,label_bound)
>>>
>>>
>>>
>>>
>>> [image: Inline image 1]
>>>
>>> On Tue, Dec 1, 2015 at 8:09 PM, Stefan van der Walt <
>>> stefanv at berkeley.edu> wrote:
>>>
>>>> On 2015-12-01 21:00:16, Arctic_python <ejsaiet at alaska.edu> wrote:
>>>> >     ndim = label_img.ndim
>>>> > AttributeError: 'list' object has no attribute 'ndim'
>>>> >
>>>> >    1. label_image=measure.label(g_median_bin, background=0) #
>>>> g_median_bin
>>>> >    is a binary image
>>>>
>>>> That does not seem to be true, given the error message.
>>>>
>>>> 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/PwmizxFahYE/unsubscribe.
>>>> To unsubscribe from this group and all its topics, send an email to
>>>> scikit-image+unsubscribe at googlegroups.com.
>>>> To post to this group, send an email to scikit-image at googlegroups.com.
>>>> To view this discussion on the web, visit
>>>> https://groups.google.com/d/msgid/scikit-image/87zixt8mie.fsf%40berkeley.edu
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> --
>>> Eyal Saiet
>>>
>>> Project manager
>>> Remote sensing and in-situ measurements
>>>
>>> Geophysical Institute
>>> University of Alaska Fairbanks
>>> Fairbanks, AK 99775
>>> (907) 750 6555 (cell)
>>>
>>> ejsaiet at alaska.edu
>>>
>>> --
>>> 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.
>>> To post to this group, send email to scikit-image at googlegroups.com.
>>> To view this discussion on the web, visit
>>> https://groups.google.com/d/msgid/scikit-image/CA%2BysReAKgzF%3DJXEjz7hti8sz0EBS_Hr%3DPaFWTxN6FV-GtROB0w%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/scikit-image/CA%2BysReAKgzF%3DJXEjz7hti8sz0EBS_Hr%3DPaFWTxN6FV-GtROB0w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> --
>> 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/PwmizxFahYE/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> scikit-image+unsubscribe at googlegroups.com.
>> To post to this group, send email to scikit-image at googlegroups.com.
>> To view this discussion on the web, visit
>> https://groups.google.com/d/msgid/scikit-image/CA%2BJHcKT5TijcW_Xa%3DEJt%2Bdi-o_3Hn5PmuHJzXc0YyM44vFr%2BDA%40mail.gmail.com
>> <https://groups.google.com/d/msgid/scikit-image/CA%2BJHcKT5TijcW_Xa%3DEJt%2Bdi-o_3Hn5PmuHJzXc0YyM44vFr%2BDA%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Eyal Saiet
>
> Project manager
> Remote sensing and in-situ measurements
>
> Geophysical Institute
> University of Alaska Fairbanks
> Fairbanks, AK 99775
> (907) 750 6555 (cell)
>
> ejsaiet at alaska.edu
>
> --
> 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.
> To post to this group, send email to scikit-image at googlegroups.com.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/scikit-image/CA%2BysReD7NpvQdJgNfk_0h9b43wSEJ1TobPG0jf_MsKj6CGxDcg%40mail.gmail.com
> <https://groups.google.com/d/msgid/scikit-image/CA%2BysReD7NpvQdJgNfk_0h9b43wSEJ1TobPG0jf_MsKj6CGxDcg%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20151202/c62ab93a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 20790 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20151202/c62ab93a/attachment.png>


More information about the scikit-image mailing list