Search in sources :

Example 1 with PointSet

use of net.imglib2.ops.pointset.PointSet in project imagej-plugins-commands by imagej.

the class MeasurementDemo method getNestedNeighborhoods.

// this returns a list of PointSets that are progressively bigger.
// for illustration.
private List<PointSet> getNestedNeighborhoods(long delta) {
    long[] zeroOrigin = new long[2];
    long[] tmpNeg = new long[] { delta, delta };
    long[] tmpPos = new long[] { delta, delta };
    List<PointSet> regions = new ArrayList<PointSet>();
    for (int i = 0; i < 5; i++) {
        PointSet ps = new HyperVolumePointSet(zeroOrigin, tmpNeg, tmpPos);
        regions.add(ps);
        tmpNeg = tmpNeg.clone();
        tmpPos = tmpPos.clone();
        tmpNeg[0]++;
        tmpNeg[1]++;
        tmpPos[0]++;
        tmpPos[1]++;
    }
    return regions;
}
Also used : PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) ArrayList(java.util.ArrayList) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet)

Example 2 with PointSet

use of net.imglib2.ops.pointset.PointSet in project imagej-plugins-commands by imagej.

the class MeasurementDemo method example5.

// measuring a custom set of data using an aggregating class
private void example5() {
    Dataset ds = getTestData();
    DoubleType output = new DoubleType();
    RealImageFunction<?, DoubleType> imgFunc = mSrv.imgFunction(ds, output);
    BasicStatsFunction<DoubleType> statFunc = new BasicStatsFunction<DoubleType>(imgFunc, new DoubleType());
    PointSet region = new HyperVolumePointSet(Intervals.dimensionsAsLongArray(ds));
    BasicStats stats = new BasicStats();
    mSrv.measure(statFunc, region, stats);
    System.out.println("mean = " + stats.getXBar());
    System.out.println("var = " + stats.getS2n1());
}
Also used : PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) Dataset(net.imagej.Dataset) DoubleType(net.imglib2.type.numeric.real.DoubleType) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) BasicStats(net.imagej.measure.BasicStats) BasicStatsFunction(net.imagej.measure.BasicStatsFunction)

Example 3 with PointSet

use of net.imglib2.ops.pointset.PointSet in project imagej-plugins-commands by imagej.

the class MeasurementDemo method example3.

// a measurement that has a metric with nondefault constructor and oob
private void example3() {
    Dataset ds = getTestData();
    DoubleType output = new DoubleType();
    OutOfBoundsFactory<UnsignedByteType, RandomAccessibleInterval<UnsignedByteType>> oobFactory = getOobFactory();
    @SuppressWarnings("unchecked") RealImageFunction<?, DoubleType> imgFuncWithOOB = new RealImageFunction<UnsignedByteType, DoubleType>((Img<UnsignedByteType>) ds.getImgPlus(), oobFactory, output);
    // force to (0,0) - tests that oob code is working
    // ds.dimension(0) / 2;
    long ctrX = 0;
    // ds.dimension(1) / 2;
    long ctrY = 0;
    long[] posDeltas = new long[] { 3, 3 };
    long[] negDeltas = new long[] { 3, 3 };
    List<PointSet> pointSets = getNestedNeighborhoods(3);
    RealAdaptiveMedianFunction<DoubleType> adapMedFunc = new RealAdaptiveMedianFunction<DoubleType>(imgFuncWithOOB, pointSets);
    PointSet region = new HyperVolumePointSet(new long[] { ctrX, ctrY }, negDeltas, posDeltas);
    mSrv.measure(adapMedFunc, region, output);
    System.out.println("adaptive median is " + output.getRealDouble());
}
Also used : RealAdaptiveMedianFunction(net.imglib2.ops.function.real.RealAdaptiveMedianFunction) Dataset(net.imagej.Dataset) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) DoubleType(net.imglib2.type.numeric.real.DoubleType) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RealImageFunction(net.imglib2.ops.function.real.RealImageFunction)

Example 4 with PointSet

use of net.imglib2.ops.pointset.PointSet in project imagej-plugins-commands by imagej.

the class MeasurementDemo method example2.

// a basic measurement with out of bounds data handling
private void example2() {
    Dataset ds = getTestData();
    DoubleType output = new DoubleType();
    OutOfBoundsFactory<UnsignedByteType, RandomAccessibleInterval<UnsignedByteType>> oobFactory = getOobFactory();
    @SuppressWarnings("unchecked") RealImageFunction<?, DoubleType> imgFuncWithOOB = new RealImageFunction<UnsignedByteType, DoubleType>((Img<UnsignedByteType>) ds.getImgPlus(), oobFactory, output);
    RealMaxFunction<DoubleType> maxFunc = new RealMaxFunction<DoubleType>(imgFuncWithOOB);
    PointSet region = new HyperVolumePointSet(Intervals.dimensionsAsLongArray(ds));
    mSrv.measure(maxFunc, region, output);
    System.out.println("max is " + output.getRealDouble());
}
Also used : PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) RealMaxFunction(net.imglib2.ops.function.real.RealMaxFunction) Dataset(net.imagej.Dataset) DoubleType(net.imglib2.type.numeric.real.DoubleType) UnsignedByteType(net.imglib2.type.numeric.integer.UnsignedByteType) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RealImageFunction(net.imglib2.ops.function.real.RealImageFunction)

Example 5 with PointSet

use of net.imglib2.ops.pointset.PointSet in project imagej-plugins-commands by imagej.

the class MeasurementDemo method calc.

// -- private helpers --
private void calc() {
    PointSet points;
    Overlay overlay = oSrv.getActiveOverlay(display);
    if (overlay != null) {
        points = new RoiPointSet(overlay.getRegionOfInterest());
    } else {
        long[] dims = Intervals.dimensionsAsLongArray(display);
        // 1st plane only
        for (int i = 2; i < dims.length; i++) {
            dims[i] = 1;
        }
        points = new HyperVolumePointSet(dims);
    }
    DoubleType output = new DoubleType();
    mSrv.measure(function, points, output);
    sSrv.showStatus(funcName + " of selected region is " + output.getRealDouble());
}
Also used : PointSet(net.imglib2.ops.pointset.PointSet) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) RoiPointSet(net.imglib2.ops.pointset.RoiPointSet) DoubleType(net.imglib2.type.numeric.real.DoubleType) HyperVolumePointSet(net.imglib2.ops.pointset.HyperVolumePointSet) Overlay(net.imagej.overlay.Overlay)

Aggregations

HyperVolumePointSet (net.imglib2.ops.pointset.HyperVolumePointSet)18 PointSet (net.imglib2.ops.pointset.PointSet)17 DoubleType (net.imglib2.type.numeric.real.DoubleType)10 Dataset (net.imagej.Dataset)9 RoiPointSet (net.imglib2.ops.pointset.RoiPointSet)9 RealImageFunction (net.imglib2.ops.function.real.RealImageFunction)5 AxisType (net.imagej.axis.AxisType)4 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)4 PointSetIterator (net.imglib2.ops.pointset.PointSetIterator)4 ArrayList (java.util.ArrayList)3 ImgPlus (net.imagej.ImgPlus)2 BasicStatsFunction (net.imagej.measure.BasicStatsFunction)2 Overlay (net.imagej.overlay.Overlay)2 RandomAccess (net.imglib2.RandomAccess)2 RealAdaptiveMedianFunction (net.imglib2.ops.function.real.RealAdaptiveMedianFunction)2 RealArithmeticMeanFunction (net.imglib2.ops.function.real.RealArithmeticMeanFunction)2 RealMaxFunction (net.imglib2.ops.function.real.RealMaxFunction)2 OutOfBoundsMirrorFactory (net.imglib2.outofbounds.OutOfBoundsMirrorFactory)2 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)2 DefaultDataset (net.imagej.DefaultDataset)1