Most efficient way to calculate average value of labelled objects within an image

Tamas H. tomio2009 at gmail.com
Fri May 13 06:03:48 EDT 2016


How about this: maskimg is the image with the labels, img is the image you
want to analyze, then:

for i in range(1, maskimg.max()):
    img[ maskimg==i].mean()
...

On Fri, May 13, 2016 at 11:54 AM, 'Robin Wilson' via scikit-image <
scikit-image at googlegroups.com> wrote:

> Hi,
>
> I have a labelled image, where each individual connected object has a
> unique integer value (eg. as produced from skimage.measure.label), and I
> want to get the mean value of these pixels from another image (eg. the
> image that I originally segmented before labelling).
>
> What is the most efficient way to do this? The naive way is to loop over
> the values in the image calculating it for each one - but I assume that
> numpy (or skimage itself) has a far better way of doing this...
>
> Thanks,
>
> Robin
>
> Dr Robin Wilson
> Research Fellow
> University of Southampton, UK
>
> --
> 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/87b5d106-00d9-44bf-a89b-bff09ca7d00b%40googlegroups.com
> <https://groups.google.com/d/msgid/scikit-image/87b5d106-00d9-44bf-a89b-bff09ca7d00b%40googlegroups.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/20160513/0093e554/attachment.html>


More information about the scikit-image mailing list