Search in sources :

Example 1 with RealAdaptiveMedianFunction

use of net.imglib2.ops.function.real.RealAdaptiveMedianFunction 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)

Aggregations

Dataset (net.imagej.Dataset)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 RealAdaptiveMedianFunction (net.imglib2.ops.function.real.RealAdaptiveMedianFunction)1 RealImageFunction (net.imglib2.ops.function.real.RealImageFunction)1 HyperVolumePointSet (net.imglib2.ops.pointset.HyperVolumePointSet)1 PointSet (net.imglib2.ops.pointset.PointSet)1 RoiPointSet (net.imglib2.ops.pointset.RoiPointSet)1 UnsignedByteType (net.imglib2.type.numeric.integer.UnsignedByteType)1 DoubleType (net.imglib2.type.numeric.real.DoubleType)1