Counting objects using label in skimage.measure
jsch at demuc.de
Wed Nov 18 23:34:26 EST 2015
set background=0 when calling the label function.
> On Nov 18, 2015, at 11:02 PM, Arctic_python <ejsaiet at alaska.edu> wrote:
> I am trying to count the number of objects(that has "ones") in a binary array. Of course I do not expect to count holes.
> But when I run the below code,
> #print (a.shape)
> propsa = measure.regionprops(img)
> length = len(propsa)
> print ('length='+str(length))
> for label in propsa:
> print (label.centroid)
> (214.23444957510378, 505.25546156532539)
> (238.77173913043478, 740.28260869565213)
> I get two objects. From reading the centroid coordinates(above), it seems it is counting the center of the white object and the cavity (can be seen in the image bellow).
> Why is this algorithm counting cavities and not only objects that are of "ones"? Is there an argument to enforce only objects and not cavities?
> Attached is the csv file if you want to try for yourself.
> <Auto Generated Inline Image 1.png>
> 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 <mailto:scikit-image+unsubscribe at googlegroups.com>.
> To post to this group, send email to scikit-image at googlegroups.com <mailto:scikit-image at googlegroups.com>.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/scikit-image/18179150-16c2-4d34-b56f-8f3e6d91401f%40googlegroups.com <https://groups.google.com/d/msgid/scikit-image/18179150-16c2-4d34-b56f-8f3e6d91401f%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout <https://groups.google.com/d/optout>.
> <4.png><4.csv><Auto Generated Inline Image 1.png>
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the scikit-image