Search in sources :

Example 6 with OutOfBoundsMirrorFactory

use of net.imglib2.outofbounds.OutOfBoundsMirrorFactory in project imagej-ops by imagej.

the class LocalThresholdTest method testLocalMeanResultsConsistency.

/**
 * @see LocalMeanThresholdIntegral
 * @see LocalMeanThreshold
 */
@Test
public void testLocalMeanResultsConsistency() {
    Img<BitType> out2 = null;
    Img<BitType> out3 = null;
    try {
        out2 = in.factory().imgFactory(new BitType()).create(in, new BitType());
        out3 = in.factory().imgFactory(new BitType()).create(in, new BitType());
    } catch (IncompatibleTypeException exc) {
        exc.printStackTrace();
    }
    // Default implementation
    ops.run(LocalMeanThreshold.class, out2, in, new RectangleShape(2, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE), 0.0);
    // Integral image-based implementation
    ops.run(LocalMeanThresholdIntegral.class, out3, in, new RectangleShape(2, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE), 0.0);
    testIterableIntervalSimilarity(out2, out3);
}
Also used : Img(net.imglib2.img.Img) ArrayImg(net.imglib2.img.array.ArrayImg) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) BitType(net.imglib2.type.logic.BitType) IncompatibleTypeException(net.imglib2.exception.IncompatibleTypeException) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 7 with OutOfBoundsMirrorFactory

use of net.imglib2.outofbounds.OutOfBoundsMirrorFactory in project imagej-ops by imagej.

the class LocalThresholdTest method testLocalContrastThreshold.

/**
 * @see LocalContrastThreshold
 */
@Test
public void testLocalContrastThreshold() {
    ops.run(LocalContrastThreshold.class, out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
    assertEquals(false, out.firstElement().get());
}
Also used : Img(net.imglib2.img.Img) ArrayImg(net.imglib2.img.array.ArrayImg) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 8 with OutOfBoundsMirrorFactory

use of net.imglib2.outofbounds.OutOfBoundsMirrorFactory in project imagej-ops by imagej.

the class LocalThresholdTest method testOpMethods.

/**
 * Test whether parameters for ops in {@link ThresholdNamespace} opmethods are
 * correctly set.
 */
@Test
public void testOpMethods() {
    ops.threshold().localMeanThreshold(out, in, new RectangleShape(3, false), 0.0);
    ops.threshold().localMeanThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 0.0);
    ops.threshold().localMeanThreshold(out, in, new DiamondShape(3), 0.0);
    ops.threshold().localMeanThreshold(out, in, new DiamondShape(3), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 0.0);
    ops.threshold().localBernsenThreshold(out, in, new RectangleShape(3, false), 1.0, Double.MAX_VALUE * 0.5);
    ops.threshold().localBernsenThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 1.0, Double.MAX_VALUE * 0.5);
    ops.threshold().localContrastThreshold(out, in, new RectangleShape(3, false));
    ops.threshold().localContrastThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().localMedianThreshold(out, in, new RectangleShape(3, false), 1.0);
    ops.threshold().localMedianThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 1.0);
    ops.threshold().localMidGreyThreshold(out, in, new RectangleShape(3, false), 1.0);
    ops.threshold().localMidGreyThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 1.0);
    ops.threshold().localNiblackThreshold(out, in, new RectangleShape(3, false), 1.0, 2.0);
    ops.threshold().localNiblackThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 1.0, 2.0);
    ops.threshold().localPhansalkarThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 0.25, 0.5);
    ops.threshold().localPhansalkarThreshold(out, in, new RectangleShape(3, false));
    ops.threshold().localSauvolaThreshold(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE), 0.5, 0.5);
    ops.threshold().localSauvolaThreshold(out, in, new RectangleShape(3, false));
    /* Locally applied global threshold ops */
    ops.threshold().huang(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().huang(out, in, new RectangleShape(3, false));
    ops.threshold().ij1(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().ij1(out, in, new RectangleShape(3, false));
    ops.threshold().intermodes(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().intermodes(out, in, new RectangleShape(3, false));
    ops.threshold().isoData(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().isoData(out, in, new RectangleShape(3, false));
    ops.threshold().li(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().li(out, in, new RectangleShape(3, false));
    ops.threshold().maxEntropy(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().maxEntropy(out, in, new RectangleShape(3, false));
    ops.threshold().maxLikelihood(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().maxLikelihood(out, in, new RectangleShape(3, false));
    ops.threshold().minError(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().minError(out, in, new RectangleShape(3, false));
    ops.threshold().minimum(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().minimum(out, in, new RectangleShape(3, false));
    ops.threshold().moments(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().moments(out, in, new RectangleShape(3, false));
    ops.threshold().otsu(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().otsu(out, in, new RectangleShape(3, false));
    ops.threshold().percentile(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().percentile(out, in, new RectangleShape(3, false));
    ops.threshold().renyiEntropy(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().renyiEntropy(out, in, new RectangleShape(3, false));
    ops.threshold().shanbhag(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().shanbhag(out, in, new RectangleShape(3, false));
    ops.threshold().triangle(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().triangle(out, in, new RectangleShape(3, false));
    ops.threshold().yen(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().yen(out, in, new RectangleShape(3, false));
    ops.threshold().rosin(out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, RandomAccessibleInterval<ByteType>>(Boundary.SINGLE));
    ops.threshold().rosin(out, in, new RectangleShape(3, false));
}
Also used : RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) DiamondShape(net.imglib2.algorithm.neighborhood.DiamondShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 9 with OutOfBoundsMirrorFactory

use of net.imglib2.outofbounds.OutOfBoundsMirrorFactory in project imagej-ops by imagej.

the class LocalThresholdTest method testLocalMeanThresholdIntegral.

/**
 * @see LocalMeanThresholdIntegral
 */
@Test
public void testLocalMeanThresholdIntegral() {
    ops.run(LocalMeanThresholdIntegral.class, out, in, new RectangleShape(3, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE), 0.0);
    assertEquals(true, out.firstElement().get());
}
Also used : Img(net.imglib2.img.Img) ArrayImg(net.imglib2.img.array.ArrayImg) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 10 with OutOfBoundsMirrorFactory

use of net.imglib2.outofbounds.OutOfBoundsMirrorFactory in project imagej-ops by imagej.

the class LocalThresholdTest method testLocalPhansalkar.

/**
 * @see LocalPhansalkarThreshold
 */
@Test
public void testLocalPhansalkar() {
    ops.run(LocalPhansalkarThreshold.class, out, normalizedIn, new RectangleShape(2, false), new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE), 0.25, 0.5);
    assertEquals(true, out.firstElement().get());
}
Also used : Img(net.imglib2.img.Img) ArrayImg(net.imglib2.img.array.ArrayImg) RectangleShape(net.imglib2.algorithm.neighborhood.RectangleShape) ByteType(net.imglib2.type.numeric.integer.ByteType) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Aggregations

RectangleShape (net.imglib2.algorithm.neighborhood.RectangleShape)35 ByteType (net.imglib2.type.numeric.integer.ByteType)35 AbstractOpTest (net.imagej.ops.AbstractOpTest)34 Img (net.imglib2.img.Img)34 Test (org.junit.Test)34 ArrayImg (net.imglib2.img.array.ArrayImg)33 IncompatibleTypeException (net.imglib2.exception.IncompatibleTypeException)4 BitType (net.imglib2.type.logic.BitType)4 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)2 OutOfBoundsMirrorFactory (net.imglib2.outofbounds.OutOfBoundsMirrorFactory)2 EigenvalueDecomposition (Jama.EigenvalueDecomposition)1 Matrix (Jama.Matrix)1 ArrayList (java.util.ArrayList)1 FinalInterval (net.imglib2.FinalInterval)1 DiamondShape (net.imglib2.algorithm.neighborhood.DiamondShape)1