regionprops - displaying region properties

ciaran.robb at googlemail.com ciaran.robb at googlemail.com
Sun Feb 1 18:45:44 EST 2015


Hello everyone,

I have recently been attempting to modify some existing skimage code to 
display regionprops for a labeled image  (e.g. area or eccentricity)

I initially tried to translate a vectorized bit of old matlab code I had, 
but gave up on that and decided to alter the existing label2rgb skimage 
function

I am attempting to change each label value to it's area property value 
similar to the label2rgb "avg" function.

so I have:
labels = a labeled image

    out = np.zeros_like(labels) #a blank array
    labels2 = np.unique(labels) #a vector of label vals
    out = np.zeros_like(labels)
    Props = regionprops(labels, ['Area'])
    bg_label=0
    bg = (labels2 == bg_label) 
    if bg.any():
        labels2 = labels2[labels2 != bg_label]
        out[bg] = 0
        for label in labels2:
            mask = (labels == label).nonzero()    
            color = Props[label].area
            out[mask] = color
but the "out" props image does not correspond to the correct area values?
Can anyone help me with this?
 It also throws the following error:
"list index out of range"
It would certainly be useful to have a way to view the spatial distribution 
of label properties in this way - perhaps in a future skimage version?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20150201/75cdcb8d/attachment.html>


More information about the scikit-image mailing list