[ImageJ-devel] Calculate overlay statistics

Curtis Rueden ctrueden at wisc.edu
Wed Jul 15 15:26:00 CDT 2015


Hi Cyril,

Awesome that you are trying out the OPS functionality.

Yes, PointSet is deprecated. The latest ROI library is in the imglib2-roi
component [1]. Unfortunately, there are not really any examples yet, since
the new API was just created in January.

The main problem you are encountering here is a clash of "layers" of the
ImageJ2 API designed at different times. The imagej-common classes
(ImageDisplay and Overlay) were created before we started OPS, so they use
the old ROI library of ImgLib2, including extensions built on top, such as
PointSets. The imagej-ops classes are much newer and IMHO well-designed,
but have mostly focused on building on top of ImgLib2 data structures. (OPS
does use the ImgPlus class but that needs to be redesigned very soon.)

Ultimately, you have two options here:

A) Stick with the deprecated-but-still-available API of PointSet and
StatisticsService [2]. You can call
StatisticsService.arithmeticMean(Dataset, PointSet) to get the answer you
are looking for here.

B) Use OPS, knowing you'll have to jump through some hoops right now as the
layers of API are "repaved." In theory, you can compute the mean of a
region using OPS, by doing something like:

   opService.stats().mean(new DoubleType(), overlay.getRegionOfInterest());

But I have not tested this. ImageJ2 components downstream from ops (e.g.,
imagej-plugins-commands) are in dire need of an update to use OPS rather
than the deprecated APIs, but we have not had time to work on it yet.

Regards,
Curtis

[1] https://github.com/imglib/imglib2-roi
[2]
https://github.com/imagej/imagej-ops/blob/imagej-ops-0.15.0/src/main/java/net/imagej/measure/StatisticsService.java

On Mon, Jul 6, 2015 at 8:19 AM, Mongis Cyril <cyril.mongis at googlemail.com>
wrote:

> Dear everyone,
>
> I'm trying to calculate the statistics of a an overlay for the active
> display.
> I try to use the PointSet but it doesn't work. The thread is just blocked :
>
> public double getMean(ImageDisplay imageDisplay, Overlay overlay) {
>      final PointSet ps = new RoiPointSet(overlay.getRegionOfInterest());
>      return (double) opService.mean(ps);
> }
>
> The PointSet API seems to be deprecated and when I dig into the Ops code,
> it seems that the statistic function just accept an iterable. From what I
> understood, PointSet are set of coordinates inside the image. I guess I
> need to associate the coordinates to a dataset and get an Iterable/Function
> out of it. Is there a service that already does this ? Or is it the wrong
> approach ?
>
> Cheers,
>
> Cyril
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20150715/656b00f3/attachment.html>


More information about the ImageJ-devel mailing list