Calculate overlay statistics

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calculate overlay statistics

Mongis Cyril
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
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel
Reply | Threaded
Open this post in threaded view
|

Re: Calculate overlay statistics

Curtis Rueden
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


On Mon, Jul 6, 2015 at 8:19 AM, Mongis Cyril <[hidden email]> 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
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel



_______________________________________________
ImageJ-devel mailing list
[hidden email]
http://imagej.net/mailman/listinfo/imagej-devel