diff --git a/.travis/settings.xml b/.travis/settings.xml index 71a56300a7..e9b968031a 100644 --- a/.travis/settings.xml +++ b/.travis/settings.xml @@ -1,14 +1,14 @@ - - - - imagej.releases - travis - ${env.MAVEN_PASS} - - - imagej.snapshots - travis - ${env.MAVEN_PASS} - - - + + + + imagej.releases + travis + ${env.MAVEN_PASS} + + + imagej.snapshots + travis + ${env.MAVEN_PASS} + + + diff --git a/images/readme.txt b/images/readme.txt index 6665775bff..efae6e5fbc 100644 --- a/images/readme.txt +++ b/images/readme.txt @@ -1,3 +1,3 @@ -These images go with the toplevel README.md file. - -They are documentation, and not necessary for ImageJ Ops to function. +These images go with the toplevel README.md file. + +They are documentation, and not necessary for ImageJ Ops to function. diff --git a/src/main/java/net/imagej/ops/create/CreateNamespace.java b/src/main/java/net/imagej/ops/create/CreateNamespace.java index e0a82af555..c87e1e912a 100644 --- a/src/main/java/net/imagej/ops/create/CreateNamespace.java +++ b/src/main/java/net/imagej/ops/create/CreateNamespace.java @@ -52,6 +52,7 @@ import net.imglib2.type.numeric.IntegerType; import net.imglib2.type.numeric.complex.ComplexDoubleType; import net.imglib2.type.numeric.complex.ComplexFloatType; +import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; @@ -107,6 +108,350 @@ public Img img(final int[] dims) { public Img img(final long[] dims) { return img(new FinalDimensions(dims), new DoubleType()); } + + // -- from array + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Bit.class) + public > Img bitArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Bit.class) + public > Img bitPlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint2.class) + public > Img uint2ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint2.class) + public > Img uint2PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint4.class) + public > Img uint4ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint4.class) + public > Img uint4PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint8.class) + public > Img uint8ArrayImg(final byte[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint8.class) + public > Img uint8PlanarImg(final byte[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Int8.class) + public > Img int8ArrayImg(final byte[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Int8.class) + public > Img int8PlanarImg(final byte[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint16.class) + public > Img uint16ArrayImg(final short[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint16.class) + public > Img uint16PlanarImg(final short[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Int16.class) + public > Img int16ArrayImg(final short[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Int16.class) + public > Img int16PlanarImg(final short[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint32.class) + public > Img uint32ArrayImg(final int[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint32.class) + public > Img uint32PlanarImg(final int[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Int32.class) + public > Img int32ArrayImg(final int[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Int32.class) + public > Img int32PlanarImg(final int[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint64.class) + public > Img uint64ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint64.class) + public > Img uint64PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Int64.class) + public > Img int64ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Int64.class) + public > Img int64PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint128.class) + public > Img uint128ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint128.class) + public > Img uint128PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Uint12.class) + public > Img uint12ArrayImg(final long[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Uint12.class) + public > Img uint12PlanarImg(final long[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.ARGB32.class) + public > Img ARGBArrayImg(final int[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.ARGB32.class) + public > Img ARGBPlanarImg(final int[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.UintVarLen.class) + public > Img uintVarLenArrayImg(final long[] in, + final Dimensions dim, final int nBits) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim, nBits); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.UintVarLen.class) + public > Img uintVarLenPlanarImg(final long[][] in, + final Dimensions dim, final int nBits) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim, nBits); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Float.class) + public > Img floatArrayImg(final float[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Float.class) + public > Img doublePlanarImg(final float[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreateArrayImgFromArray.Double.class) + public > Img doubleArrayImg(final double[] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + @OpMethod(op = net.imagej.ops.create.img.CreatePlanarImgFromArray.Double.class) + public > Img doublePlanarImg(final double[][] in, + final Dimensions dim) + { + @SuppressWarnings("unchecked") + final Img result = (Img) ops().run( + Ops.Create.Img.class, in, dim); + return result; + } + + // -- @OpMethod(op = net.imagej.ops.create.img.CreateImgFromDimsAndType.class) public > Img img(final Dimensions in1, diff --git a/src/main/java/net/imagej/ops/create/img/CreateArrayImgFromArray.java b/src/main/java/net/imagej/ops/create/img/CreateArrayImgFromArray.java new file mode 100644 index 0000000000..bd631e30f4 --- /dev/null +++ b/src/main/java/net/imagej/ops/create/img/CreateArrayImgFromArray.java @@ -0,0 +1,285 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2017 ImageJ developers. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.create.img; + +import java.lang.reflect.Array; +import org.scijava.Priority; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.function.AbstractUnaryFunctionOp; +import net.imglib2.Dimensions; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImg; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.img.basictypeaccess.array.LongArray; +import net.imglib2.type.NativeType; +import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.ARGBType; +import net.imglib2.type.numeric.integer.*; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +/** + * Create an {@link ArrayImg} from an array using its type + * {@code T}. + * + * @author Dasong Gao + */ +@SuppressWarnings("deprecation") +public class CreateArrayImgFromArray { + + // hide constructor + private CreateArrayImgFromArray() { + + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Bit extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 1 / 64f; } + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.bits(new LongArray(in), this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint2 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 2 / 64f; } + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.unsigned2Bits(new LongArray(in), this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint4 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 4 / 64f; } + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.unsigned4Bits(new LongArray(in), this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int8 extends FromArray { + + @Override + public Img asArrayImg(byte[] in) { + return ArrayImgs.bytes(in, this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint8 extends FromArray { + + @Override + public Img asArrayImg(byte[] in) { + return ArrayImgs.unsignedBytes(in, this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint12 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 12 / 64f; } + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.unsigned12Bits(new LongArray(in), this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int16 extends FromArray { + + @Override + public Img asArrayImg(short[] in) { + return ArrayImgs.shorts(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint16 extends FromArray { + + @Override + public Img asArrayImg(short[] in) { + return ArrayImgs.unsignedShorts(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int32 extends FromArray { + + @Override + public Img asArrayImg(int[] in) { + return ArrayImgs.ints(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint32 extends FromArray { + + @Override + public Img asArrayImg(int[] in) { + return ArrayImgs.unsignedInts(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class ARGB32 extends FromArray { + + @Override + public Img asArrayImg(int[] in) { + return ArrayImgs.argbs(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int64 extends FromArray { + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.longs(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint64 extends FromArray { + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.unsignedLongs(in, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint128 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 128 / 64f; } + + public Img asArrayImg(long[] in) { + return ArrayImgs.unsigned128Bits(new LongArray(in), imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class UintVarLen extends FromArray { + + // number of bits of the number + @Parameter(required = true) + private int nBits; + + @Override + protected void updateEPE() { elementsPerPixel = nBits / 64f; } + + @Override + public Img asArrayImg(long[] in) { + return ArrayImgs.unsignedVariableBitLengths(new LongArray(in), nBits, imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Float extends FromArray { + + @Override + public Img asArrayImg(float[] in) { + return ArrayImgs.floats(in, this.imgDims); + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Double extends FromArray { + + @Override + public Img asArrayImg(double[] in) { + return ArrayImgs.doubles(in, this.imgDims); + } + } + + // helper class for wrapping + private static abstract class FromArray> + extends AbstractUnaryFunctionOp> + implements Ops.Create.Img, Contingent { + + // image dimensions + @Parameter(required = true) + private Dimensions dims; + + // image dimensions (unpacked from dims) + protected long[] imgDims; + + // used to scale for Bit, 12Bit, 128Bit, varBit, etc. + protected float elementsPerPixel = 1.0f; + + @Override + public Img calculate(final I inArray) { + return this.asArrayImg((I)inArray); + } + + @Override + public boolean conforms() { + updateEPE(); + imgDims = new long[dims.numDimensions()]; + if (imgDims.length == 0) + return false; + int numPixel = 1; + for (int i = 0; i < imgDims.length; i++) + numPixel *= imgDims[i] = dims.dimension(i); + + I in = this.in(); + return in.getClass().isArray() && numPixel != 0 + && (int) Math.ceil((numPixel * elementsPerPixel)) == Array.getLength(in); + } + + @Override + public Img run(Img output) { + return null; + } + + protected abstract Img asArrayImg(I in); + + // update entitiesPerElement before checking size + protected void updateEPE() {}; + } +} diff --git a/src/main/java/net/imagej/ops/create/img/CreatePlanarImgFromArray.java b/src/main/java/net/imagej/ops/create/img/CreatePlanarImgFromArray.java new file mode 100644 index 0000000000..d6433d19cd --- /dev/null +++ b/src/main/java/net/imagej/ops/create/img/CreatePlanarImgFromArray.java @@ -0,0 +1,377 @@ +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2017 ImageJ developers. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.create.img; + +import java.lang.reflect.Array; +import org.scijava.Priority; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.function.AbstractUnaryFunctionOp; +import net.imglib2.Dimensions; +import net.imglib2.img.Img; +import net.imglib2.img.basictypeaccess.array.ByteArray; +import net.imglib2.img.basictypeaccess.array.DoubleArray; +import net.imglib2.img.basictypeaccess.array.FloatArray; +import net.imglib2.img.basictypeaccess.array.IntArray; +import net.imglib2.img.basictypeaccess.array.LongArray; +import net.imglib2.img.basictypeaccess.array.ShortArray; +import net.imglib2.img.planar.PlanarImg; +import net.imglib2.img.planar.PlanarImgFactory; +import net.imglib2.type.NativeType; +import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.ARGBType; +import net.imglib2.type.numeric.integer.*; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +/** + * Create an {@link PlanarImg} from an array using its type + * {@code T}. The first two dimensions (first one if it is + * the only dimension) in parameter dims are used as sizes + * of planes. Any other dimensions are flattened to produce + * a list of planar slices. + * + * @author Dasong Gao + */ +@SuppressWarnings("unchecked") +public class CreatePlanarImgFromArray { + + // hide constructor + private CreatePlanarImgFromArray() { + + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Bit extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 1 / 64f; } + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new BitType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint2 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 2 / 64f; } + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new Unsigned2BitType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint4 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 4 / 64f; } + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new Unsigned4BitType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int8 extends FromArray { + + @Override + public Img asPlanarImg(byte[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new ByteType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new ByteArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint8 extends FromArray { + + @Override + public Img asPlanarImg(byte[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new UnsignedByteType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new ByteArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint12 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 12 / 64f; } + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new Unsigned12BitType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int16 extends FromArray { + + @Override + public Img asPlanarImg(short[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new ShortType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new ShortArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint16 extends FromArray { + + @Override + public Img asPlanarImg(short[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new UnsignedShortType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new ShortArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int32 extends FromArray { + + @Override + public Img asPlanarImg(int[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new IntType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new IntArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint32 extends FromArray { + + @Override + public Img asPlanarImg(int[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new UnsignedIntType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new IntArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class ARGB32 extends FromArray { + + @Override + public Img asPlanarImg(int[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new ARGBType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new IntArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Int64 extends FromArray { + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new LongType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint64 extends FromArray { + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new UnsignedLongType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Uint128 extends FromArray { + + @Override + protected void updateEPE() { elementsPerPixel = 128 / 64f; } + + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new Unsigned128BitType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class UintVarLen extends FromArray { + + // number of bits of the number + @Parameter(required = true) + private int nBits; + + @Override + protected void updateEPE() { elementsPerPixel = nBits / 64f; } + + + @Override + public Img asPlanarImg(long[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, + new UnsignedVariableBitLengthType(nBits)); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new LongArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Float extends FromArray { + + @Override + public Img asPlanarImg(float[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new FloatType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new FloatArray(in[i])); + return output; + } + } + + @Plugin(type = Ops.Create.Img.class, priority = Priority.HIGH_PRIORITY) + public static class Double extends FromArray { + + @Override + public Img asPlanarImg(double[][] in) { + PlanarImg output = + (PlanarImg) factory.create(imgDims, new DoubleType()); + for (int i = 0; i < in.length; i++) + output.setPlane(i, new DoubleArray(in[i])); + return output; + } + } + + // helper class for wrapping + private static abstract class FromArray> + extends AbstractUnaryFunctionOp> + implements Ops.Create.Img, Contingent { + + // image dimensions + @Parameter(required = true) + private Dimensions dims; + + // image dimensions (unpacked from dims) + protected long[] imgDims; + + // used to scale for Bit, 12Bit, 128Bit, varBit, etc. + protected float elementsPerPixel = 1.0f; + + protected PlanarImgFactory factory = new PlanarImgFactory(); + + @Override + public Img calculate(final I[] inArray) { + return this.asPlanarImg(inArray); + } + + @Override + public boolean conforms() { + updateEPE(); + imgDims = new long[dims.numDimensions()]; + if (imgDims.length == 0) + return false; + int numPlane = 1; + for (int i = 0; i < imgDims.length; i++) { + imgDims[i] = dims.dimension(i); + if (i >= 2) + numPlane *= imgDims[i]; + } + + I[] in = this.in(); + + int sliceSize = (int) imgDims[0]; + if (imgDims.length >= 2) + sliceSize *= imgDims[1]; + // number of array elements for a single plane + int elementsPerPlane = (int) Math.ceil(sliceSize * elementsPerPixel); + for (Object i : in) { + if (!i.getClass().isArray() || Array.getLength(i) != elementsPerPlane) + return false; + } + return in.length == numPlane; + } + + @Override + public Img run(Img output) { + return null; + } + + protected abstract Img asPlanarImg(I[] in); + + // update entitiesPerElement before checking size + protected void updateEPE() {}; + } +} diff --git a/src/main/templates/net/imagej/ops/Ops.vm b/src/main/templates/net/imagej/ops/Ops.vm index b9c7b35812..c6a0c66436 100644 --- a/src/main/templates/net/imagej/ops/Ops.vm +++ b/src/main/templates/net/imagej/ops/Ops.vm @@ -1,115 +1,115 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops; - -import net.imagej.ops.Op; - -/** - * Static utility class containing built-in op interfaces. - *

- * These interfaces are intended to mark all ops using a particular name, - * regardless of their exact functionality. For example, all ops called "eval" - * would be marked by implementing the {@code Ops.Eval} interface, and - * annotating them with: - *

- * - * {@code @Plugin(type = Ops.Eval.class)} - * -#foreach ($author in $authors) - * @author $author -#end - */ -public final class Ops { - - private Ops() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($opClass = $op.iface) - - /** - * Base interface for "$op.name" operations. - *

- * Implementing classes should be annotated with: - *

- * - * {@code @Plugin(type = Ops.${opClass}.class)} - */ - public interface $opClass extends Op { - String NAME = "$op.name"; -#if ($op.aliases) - String ALIASES = "## -#set ($first = true) -#foreach ($alias in $op.aliases) -#if ($first)#set ($first = false)#else, #end -$alias## -#end##foreach ($alias in $op.aliases) -"; -#end##if ($op.aliases) - } -#end##foreach ($op in $ops) -#foreach ($ns in $namespaces) -#set ($nsClass = $ns.iface) - - /** Built-in op interfaces of the $ns.name namespace. */ - public static final class $nsClass { - - private $nsClass() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ns.ops) -#set ($opClass = $op.iface) - - /** - * Base interface for "$op.name" operations. - *

- * Implementing classes should be annotated with: - *

- * - * {@code @Plugin(type = Ops.${nsClass}.${opClass}.class)} - */ - public interface $opClass extends Op { - String NAME = "${ns.name}.$op.name"; -#if ($op.aliases) - String ALIASES = "## -#set ($first = true) -#foreach ($alias in $op.aliases) -#if ($first)#set ($first = false)#else, #end -${ns.name}.$alias## -#end##foreach ($alias in $op.aliases) -"; -#end##if ($op.aliases) - } -#end##foreach ($op in $ns.ops) - } -#end##foreach ($ns in $namespaces) - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops; + +import net.imagej.ops.Op; + +/** + * Static utility class containing built-in op interfaces. + *

+ * These interfaces are intended to mark all ops using a particular name, + * regardless of their exact functionality. For example, all ops called "eval" + * would be marked by implementing the {@code Ops.Eval} interface, and + * annotating them with: + *

+ * + * {@code @Plugin(type = Ops.Eval.class)} + * +#foreach ($author in $authors) + * @author $author +#end + */ +public final class Ops { + + private Ops() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($opClass = $op.iface) + + /** + * Base interface for "$op.name" operations. + *

+ * Implementing classes should be annotated with: + *

+ * + * {@code @Plugin(type = Ops.${opClass}.class)} + */ + public interface $opClass extends Op { + String NAME = "$op.name"; +#if ($op.aliases) + String ALIASES = "## +#set ($first = true) +#foreach ($alias in $op.aliases) +#if ($first)#set ($first = false)#else, #end +$alias## +#end##foreach ($alias in $op.aliases) +"; +#end##if ($op.aliases) + } +#end##foreach ($op in $ops) +#foreach ($ns in $namespaces) +#set ($nsClass = $ns.iface) + + /** Built-in op interfaces of the $ns.name namespace. */ + public static final class $nsClass { + + private $nsClass() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ns.ops) +#set ($opClass = $op.iface) + + /** + * Base interface for "$op.name" operations. + *

+ * Implementing classes should be annotated with: + *

+ * + * {@code @Plugin(type = Ops.${nsClass}.${opClass}.class)} + */ + public interface $opClass extends Op { + String NAME = "${ns.name}.$op.name"; +#if ($op.aliases) + String ALIASES = "## +#set ($first = true) +#foreach ($alias in $op.aliases) +#if ($first)#set ($first = false)#else, #end +${ns.name}.$alias## +#end##foreach ($alias in $op.aliases) +"; +#end##if ($op.aliases) + } +#end##foreach ($op in $ns.ops) + } +#end##foreach ($ns in $namespaces) + +} diff --git a/src/main/templates/net/imagej/ops/convert/ConvertImages.list b/src/main/templates/net/imagej/ops/convert/ConvertImages.list index 40006bfde3..0695b3f39b 100644 --- a/src/main/templates/net/imagej/ops/convert/ConvertImages.list +++ b/src/main/templates/net/imagej/ops/convert/ConvertImages.list @@ -1,22 +1,22 @@ -[ConvertImages.java] -ops = ``` -[ - [name: "Bit", type: "net.imglib2.type.logic.BitType"], - [name: "Uint2", type: "net.imglib2.type.numeric.integer.Unsigned2BitType"], - [name: "Uint4", type: "net.imglib2.type.numeric.integer.Unsigned4BitType"], - [name: "Int8", type: "net.imglib2.type.numeric.integer.ByteType"], - [name: "Uint8", type: "net.imglib2.type.numeric.integer.UnsignedByteType"], - [name: "Uint12", type: "net.imglib2.type.numeric.integer.Unsigned12BitType"], - [name: "Int16", type: "net.imglib2.type.numeric.integer.ShortType"], - [name: "Uint16", type: "net.imglib2.type.numeric.integer.UnsignedShortType"], - [name: "Int32", type: "net.imglib2.type.numeric.integer.IntType"], - [name: "Uint32", type: "net.imglib2.type.numeric.integer.UnsignedIntType"], - [name: "Int64", type: "net.imglib2.type.numeric.integer.LongType"], - [name: "Uint64", type: "net.imglib2.type.numeric.integer.UnsignedLongType"], - [name: "Uint128", type: "net.imglib2.type.numeric.integer.Unsigned128BitType"], - [name: "Float32", type: "net.imglib2.type.numeric.real.FloatType"], - [name: "Float64", type: "net.imglib2.type.numeric.real.DoubleType"], - [name: "Cfloat32", type: "net.imglib2.type.numeric.complex.ComplexFloatType"], - [name: "Cfloat64", type: "net.imglib2.type.numeric.complex.ComplexDoubleType"], -] -``` +[ConvertImages.java] +ops = ``` +[ + [name: "Bit", type: "net.imglib2.type.logic.BitType"], + [name: "Uint2", type: "net.imglib2.type.numeric.integer.Unsigned2BitType"], + [name: "Uint4", type: "net.imglib2.type.numeric.integer.Unsigned4BitType"], + [name: "Int8", type: "net.imglib2.type.numeric.integer.ByteType"], + [name: "Uint8", type: "net.imglib2.type.numeric.integer.UnsignedByteType"], + [name: "Uint12", type: "net.imglib2.type.numeric.integer.Unsigned12BitType"], + [name: "Int16", type: "net.imglib2.type.numeric.integer.ShortType"], + [name: "Uint16", type: "net.imglib2.type.numeric.integer.UnsignedShortType"], + [name: "Int32", type: "net.imglib2.type.numeric.integer.IntType"], + [name: "Uint32", type: "net.imglib2.type.numeric.integer.UnsignedIntType"], + [name: "Int64", type: "net.imglib2.type.numeric.integer.LongType"], + [name: "Uint64", type: "net.imglib2.type.numeric.integer.UnsignedLongType"], + [name: "Uint128", type: "net.imglib2.type.numeric.integer.Unsigned128BitType"], + [name: "Float32", type: "net.imglib2.type.numeric.real.FloatType"], + [name: "Float64", type: "net.imglib2.type.numeric.real.DoubleType"], + [name: "Cfloat32", type: "net.imglib2.type.numeric.complex.ComplexFloatType"], + [name: "Cfloat64", type: "net.imglib2.type.numeric.complex.ComplexDoubleType"], +] +``` diff --git a/src/main/templates/net/imagej/ops/convert/ConvertImages.vm b/src/main/templates/net/imagej/ops/convert/ConvertImages.vm index 3e6e17c15b..fa8ccd7f7f 100644 --- a/src/main/templates/net/imagej/ops/convert/ConvertImages.vm +++ b/src/main/templates/net/imagej/ops/convert/ConvertImages.vm @@ -1,119 +1,119 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.convert; - -import net.imagej.ops.Op; -import net.imagej.ops.Ops; -import net.imagej.ops.special.chain.UHCFViaUCSameIO; -import net.imagej.ops.special.computer.Computers; -import net.imagej.ops.special.computer.UnaryComputerOp; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.type.NativeType; -import net.imglib2.type.numeric.ComplexType; -#set ($imports = []) -#foreach ($op in $ops) -#set($result = $imports.add($op.type)) -#end -#* -NB: Sort the list. We access the Collections class via reflection, since -Velocity does not have a built-in syntax for importing Java classes. -Credit to Martin Gamulin for the idea: http://stackoverflow.com/a/7672699 -*# -#set($Collections = $ops.getClass().forName("java.util.Collections")) -#set($result = $Collections.sort($imports)) -#foreach ($import in $imports) -import $import; -#end - -import org.scijava.plugin.Plugin; - -/** - * Ops for converting images between types. - *

- * These ops work by feeding the {@link ConvertTypes} ops to {@code map}. - *

- * - * @author Curtis Rueden - */ -public final class ConvertImages { - - private ConvertImages() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($opType = $op.name) -#set ($dot = $op.type.lastIndexOf(".") + 1) -#set ($imglibType = $op.type.substring($dot)) - - @Plugin(type = Ops.Convert.${opType}.class) - public static class $opType> extends - ConvertViaMap implements - Ops.Convert.$opType - { - public $opType() { - super(Ops.Convert.${opType}.class, new $imglibType()); - } - } -#end - - // -- Helper classes -- - - private abstract static class ConvertViaMap, O extends NativeType> - extends UHCFViaUCSameIO, Img> - { - - private Class opType; - private O outElement; - - protected ConvertViaMap(Class opType, O outElement) { - this.opType = opType; - this.outElement = outElement; - } - - @Override - public UnaryComputerOp, Img> createWorker( - final IterableInterval t) - { - final I inElement = t.firstElement(); - final UnaryComputerOp elementOp = Computers.unary(ops(), opType, - outElement, inElement); - return (UnaryComputerOp) - Computers.unary(ops(), Ops.Map.class, Img.class, t, elementOp); - } - - @Override - public Img createOutput(final IterableInterval input) { - return ops().create().img(input, outElement); - } - } - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.convert; + +import net.imagej.ops.Op; +import net.imagej.ops.Ops; +import net.imagej.ops.special.chain.UHCFViaUCSameIO; +import net.imagej.ops.special.computer.Computers; +import net.imagej.ops.special.computer.UnaryComputerOp; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.type.NativeType; +import net.imglib2.type.numeric.ComplexType; +#set ($imports = []) +#foreach ($op in $ops) +#set($result = $imports.add($op.type)) +#end +#* +NB: Sort the list. We access the Collections class via reflection, since +Velocity does not have a built-in syntax for importing Java classes. +Credit to Martin Gamulin for the idea: http://stackoverflow.com/a/7672699 +*# +#set($Collections = $ops.getClass().forName("java.util.Collections")) +#set($result = $Collections.sort($imports)) +#foreach ($import in $imports) +import $import; +#end + +import org.scijava.plugin.Plugin; + +/** + * Ops for converting images between types. + *

+ * These ops work by feeding the {@link ConvertTypes} ops to {@code map}. + *

+ * + * @author Curtis Rueden + */ +public final class ConvertImages { + + private ConvertImages() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($opType = $op.name) +#set ($dot = $op.type.lastIndexOf(".") + 1) +#set ($imglibType = $op.type.substring($dot)) + + @Plugin(type = Ops.Convert.${opType}.class) + public static class $opType> extends + ConvertViaMap implements + Ops.Convert.$opType + { + public $opType() { + super(Ops.Convert.${opType}.class, new $imglibType()); + } + } +#end + + // -- Helper classes -- + + private abstract static class ConvertViaMap, O extends NativeType> + extends UHCFViaUCSameIO, Img> + { + + private Class opType; + private O outElement; + + protected ConvertViaMap(Class opType, O outElement) { + this.opType = opType; + this.outElement = outElement; + } + + @Override + public UnaryComputerOp, Img> createWorker( + final IterableInterval t) + { + final I inElement = t.firstElement(); + final UnaryComputerOp elementOp = Computers.unary(ops(), opType, + outElement, inElement); + return (UnaryComputerOp) + Computers.unary(ops(), Ops.Map.class, Img.class, t, elementOp); + } + + @Override + public Img createOutput(final IterableInterval input) { + return ops().create().img(input, outElement); + } + } + +} diff --git a/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.list b/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.list index 83e17720fb..4487003ade 100644 --- a/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.list +++ b/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.list @@ -1,6 +1,6 @@ -# Generated binary arithmetic ops with IterableIntervals and output to -# IterableIntervals. - -[IIToIIOutputII.java] - -ops = ["And", "Or", "Xor"] +# Generated binary arithmetic ops with IterableIntervals and output to +# IterableIntervals. + +[IIToIIOutputII.java] + +ops = ["And", "Or", "Xor"] diff --git a/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.vm b/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.vm index 9671859679..ea0e99261f 100644 --- a/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.vm +++ b/src/main/templates/net/imagej/ops/logic/IIToIIOutputII.vm @@ -1,120 +1,120 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Op; -import net.imagej.ops.Ops; -import net.imagej.ops.map.Maps; -import net.imagej.ops.special.computer.BinaryComputerOp; -import net.imagej.ops.special.computer.Computers; -import net.imagej.ops.special.function.Functions; -import net.imagej.ops.special.function.UnaryFunctionOp; -import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; -import net.imagej.ops.special.hybrid.Hybrids; -import net.imagej.ops.special.inplace.BinaryInplaceOp; -import net.imagej.ops.special.inplace.Inplaces; -import net.imglib2.IterableInterval; -import net.imglib2.type.BooleanType; - -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary logic operations between {@link IterableInterval}s - * and writes result to {@link IterableInterval}s. - * - * @author Leon Yang - */ -public final class IIToIIOutputII { - - private IIToIIOutputII() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Logic.$op") - - @Plugin(type = ${iface}.class) - public static class ${op}> extends - AbstractBinaryHybridCFI, IterableInterval> - implements $iface, Contingent - { - - private UnaryFunctionOp, IterableInterval> outputCreator; - private BinaryComputerOp, IterableInterval, IterableInterval> mapper; - private BinaryInplaceOp, IterableInterval> inplaceMapper; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void initialize() { - outputCreator = (UnaryFunctionOp) Functions.unary(ops(), - Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() - .createVariable()); - if (out() == null) setOutput(createOutput()); - final Op op = Hybrids.binaryCI(ops(), Ops.Logic.${op}.class, BooleanType.class, BooleanType.class); - mapper = Computers.binary(ops(), Ops.Map.class, out(), in1(), in2(), op); - inplaceMapper = Inplaces.binary(ops(), Ops.Map.class, in1(), in2(), op); - } - - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2(), out()); - } - - @Override - public IterableInterval createOutput(final IterableInterval input1, - final IterableInterval input2) - { - return outputCreator.calculate(input1); - } - - @Override - public void compute(final IterableInterval input1, - final IterableInterval input2, final IterableInterval output) - { - mapper.compute(input1, input2, output); - } - - @Override - public void mutate1(final IterableInterval arg, - final IterableInterval in) - { - inplaceMapper.mutate1(arg, in); - } - - @Override - public void mutate2(final IterableInterval in, - final IterableInterval arg) - { - inplaceMapper.mutate2(in, arg); - } - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Op; +import net.imagej.ops.Ops; +import net.imagej.ops.map.Maps; +import net.imagej.ops.special.computer.BinaryComputerOp; +import net.imagej.ops.special.computer.Computers; +import net.imagej.ops.special.function.Functions; +import net.imagej.ops.special.function.UnaryFunctionOp; +import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; +import net.imagej.ops.special.hybrid.Hybrids; +import net.imagej.ops.special.inplace.BinaryInplaceOp; +import net.imagej.ops.special.inplace.Inplaces; +import net.imglib2.IterableInterval; +import net.imglib2.type.BooleanType; + +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary logic operations between {@link IterableInterval}s + * and writes result to {@link IterableInterval}s. + * + * @author Leon Yang + */ +public final class IIToIIOutputII { + + private IIToIIOutputII() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Logic.$op") + + @Plugin(type = ${iface}.class) + public static class ${op}> extends + AbstractBinaryHybridCFI, IterableInterval> + implements $iface, Contingent + { + + private UnaryFunctionOp, IterableInterval> outputCreator; + private BinaryComputerOp, IterableInterval, IterableInterval> mapper; + private BinaryInplaceOp, IterableInterval> inplaceMapper; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void initialize() { + outputCreator = (UnaryFunctionOp) Functions.unary(ops(), + Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() + .createVariable()); + if (out() == null) setOutput(createOutput()); + final Op op = Hybrids.binaryCI(ops(), Ops.Logic.${op}.class, BooleanType.class, BooleanType.class); + mapper = Computers.binary(ops(), Ops.Map.class, out(), in1(), in2(), op); + inplaceMapper = Inplaces.binary(ops(), Ops.Map.class, in1(), in2(), op); + } + + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2(), out()); + } + + @Override + public IterableInterval createOutput(final IterableInterval input1, + final IterableInterval input2) + { + return outputCreator.calculate(input1); + } + + @Override + public void compute(final IterableInterval input1, + final IterableInterval input2, final IterableInterval output) + { + mapper.compute(input1, input2, output); + } + + @Override + public void mutate1(final IterableInterval arg, + final IterableInterval in) + { + inplaceMapper.mutate1(arg, in); + } + + @Override + public void mutate2(final IterableInterval in, + final IterableInterval arg) + { + inplaceMapper.mutate2(in, arg); + } + } +#end +} diff --git a/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.list b/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.list index 51e24c2bf4..b499400a3a 100644 --- a/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.list +++ b/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.list @@ -1,6 +1,6 @@ -# Generated binary arithmetic ops with IterableIntervals and -# RandomAccessibleIntervals, and output to IterableIntervals. - -[IIToRAIOutputII.java] - -ops = ["And", "Or", "Xor"] +# Generated binary arithmetic ops with IterableIntervals and +# RandomAccessibleIntervals, and output to IterableIntervals. + +[IIToRAIOutputII.java] + +ops = ["And", "Or", "Xor"] diff --git a/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.vm b/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.vm index 645c6f7cf3..2b749fc75e 100644 --- a/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.vm +++ b/src/main/templates/net/imagej/ops/logic/IIToRAIOutputII.vm @@ -1,117 +1,117 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Op; -import net.imagej.ops.Ops; -import net.imagej.ops.map.Maps; -import net.imagej.ops.special.computer.BinaryComputerOp; -import net.imagej.ops.special.computer.Computers; -import net.imagej.ops.special.function.Functions; -import net.imagej.ops.special.function.UnaryFunctionOp; -import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1; -import net.imagej.ops.special.hybrid.Hybrids; -import net.imagej.ops.special.inplace.BinaryInplace1Op; -import net.imagej.ops.special.inplace.Inplaces; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.type.BooleanType; -import net.imglib2.type.numeric.NumericType; - -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary math operations between {@link IterableInterval}s - * and {@link RandomAccessibleInterval}s, and writes the result to - * {@link IterableInterval}s. - * - * @author Leon Yang - */ -public final class IIToRAIOutputII { - - private IIToRAIOutputII() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Logic.$op") - - @Plugin(type = ${iface}.class) - public static class ${op}> extends - AbstractBinaryHybridCFI1, RandomAccessibleInterval, IterableInterval> - implements $iface, Contingent - { - - private UnaryFunctionOp, IterableInterval> outputCreator; - private BinaryComputerOp, RandomAccessibleInterval, IterableInterval> mapper; - private BinaryInplace1Op, RandomAccessibleInterval, IterableInterval> inplaceMapper; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void initialize() { - outputCreator = (UnaryFunctionOp) Functions.unary(ops(), - Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() - .createVariable()); - if (out() == null) setOutput(createOutput()); - final Op op = Hybrids.binaryCI1(ops(), Ops.Logic.${op}.class, BooleanType.class, BooleanType.class, BooleanType.class); - mapper = Computers.binary(ops(), Ops.Map.class, out(), in1(), in2(), op); - inplaceMapper = Inplaces.binary1(ops(), Ops.Map.class, in1(), in2(), op); - } - - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2(), out()); - } - - @Override - public IterableInterval createOutput(final IterableInterval input1, - final RandomAccessibleInterval input2) - { - return outputCreator.calculate(input1); - } - - @Override - public void compute(final IterableInterval input1, - final RandomAccessibleInterval input2, - final IterableInterval output) - { - mapper.compute(input1, input2, output); - } - - @Override - public void mutate1(final IterableInterval arg, - final RandomAccessibleInterval in) - { - inplaceMapper.mutate1(arg, in); - } - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Op; +import net.imagej.ops.Ops; +import net.imagej.ops.map.Maps; +import net.imagej.ops.special.computer.BinaryComputerOp; +import net.imagej.ops.special.computer.Computers; +import net.imagej.ops.special.function.Functions; +import net.imagej.ops.special.function.UnaryFunctionOp; +import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1; +import net.imagej.ops.special.hybrid.Hybrids; +import net.imagej.ops.special.inplace.BinaryInplace1Op; +import net.imagej.ops.special.inplace.Inplaces; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.type.BooleanType; +import net.imglib2.type.numeric.NumericType; + +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary math operations between {@link IterableInterval}s + * and {@link RandomAccessibleInterval}s, and writes the result to + * {@link IterableInterval}s. + * + * @author Leon Yang + */ +public final class IIToRAIOutputII { + + private IIToRAIOutputII() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Logic.$op") + + @Plugin(type = ${iface}.class) + public static class ${op}> extends + AbstractBinaryHybridCFI1, RandomAccessibleInterval, IterableInterval> + implements $iface, Contingent + { + + private UnaryFunctionOp, IterableInterval> outputCreator; + private BinaryComputerOp, RandomAccessibleInterval, IterableInterval> mapper; + private BinaryInplace1Op, RandomAccessibleInterval, IterableInterval> inplaceMapper; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void initialize() { + outputCreator = (UnaryFunctionOp) Functions.unary(ops(), + Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() + .createVariable()); + if (out() == null) setOutput(createOutput()); + final Op op = Hybrids.binaryCI1(ops(), Ops.Logic.${op}.class, BooleanType.class, BooleanType.class, BooleanType.class); + mapper = Computers.binary(ops(), Ops.Map.class, out(), in1(), in2(), op); + inplaceMapper = Inplaces.binary1(ops(), Ops.Map.class, in1(), in2(), op); + } + + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2(), out()); + } + + @Override + public IterableInterval createOutput(final IterableInterval input1, + final RandomAccessibleInterval input2) + { + return outputCreator.calculate(input1); + } + + @Override + public void compute(final IterableInterval input1, + final RandomAccessibleInterval input2, + final IterableInterval output) + { + mapper.compute(input1, input2, output); + } + + @Override + public void mutate1(final IterableInterval arg, + final RandomAccessibleInterval in) + { + inplaceMapper.mutate1(arg, in); + } + } +#end +} diff --git a/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.list b/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.list index 3870330855..80b9b07903 100644 --- a/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.list +++ b/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.list @@ -1,26 +1,26 @@ -# Generated unary and binary logical ops with primitive types. - -[PrimitiveLogic.java] -types = ``` -[ - [name: "Boolean", primitive: "boolean", code: "b", priority: 0.5], - [name: "Integer", primitive: "int", code: "i", priority: 0.4], - [name: "Long", primitive: "long", code: "l", priority: 0.3], - [name: "Float", primitive: "float", code: "f", priority: 0.2], - [name: "Double", primitive: "double", code: "d", priority: 0.1] -] -``` -ops = ``` -[ - [name: "And", operator: "&&", unary: false, codes: "b", verbs: "computes the logical AND ({@literal &&}) of"], - [name: "Equal", operator: "==", unary: false, codes: "bilfd", verbs: "tests for equality ({@literal ==}) between"], - [name: "GreaterThan", operator: ">", unary: false, codes: "ilfd", verbs: "performs a greater-than ({@literal >}) comparison on"], - [name: "GreaterThanOrEqual", operator: ">=", unary: false, codes: "ilfd", verbs: "performs a greater-than-or-equal ({@literal >=}) comparison on"], - [name: "LessThan", operator: "<", unary: false, codes: "ilfd", verbs: "performs a less-than ({@literal <}) comparison on"], - [name: "LessThanOrEqual", operator: "<=", unary: false, codes: "ilfd", verbs: "performs a less-than-or-equal ({@literal <=}) comparison on"], - [name: "Not", operator: "!", unary: true, codes: "b", verbs: "computes the logical NOT ({@literal !}) of"], - [name: "NotEqual", operator: "!=", unary: false, codes: "bilfd", verbs: "tests for inequality ({@literal !=}) between"], - [name: "Or", operator: "||", unary: false, codes: "b", verbs: "computes the logical OR ({@literal ||}) of"], - [name: "Xor", operator: "^", unary: false, codes: "b", verbs: "computes the logical XOR ({@literal ^}) of"] -] -``` +# Generated unary and binary logical ops with primitive types. + +[PrimitiveLogic.java] +types = ``` +[ + [name: "Boolean", primitive: "boolean", code: "b", priority: 0.5], + [name: "Integer", primitive: "int", code: "i", priority: 0.4], + [name: "Long", primitive: "long", code: "l", priority: 0.3], + [name: "Float", primitive: "float", code: "f", priority: 0.2], + [name: "Double", primitive: "double", code: "d", priority: 0.1] +] +``` +ops = ``` +[ + [name: "And", operator: "&&", unary: false, codes: "b", verbs: "computes the logical AND ({@literal &&}) of"], + [name: "Equal", operator: "==", unary: false, codes: "bilfd", verbs: "tests for equality ({@literal ==}) between"], + [name: "GreaterThan", operator: ">", unary: false, codes: "ilfd", verbs: "performs a greater-than ({@literal >}) comparison on"], + [name: "GreaterThanOrEqual", operator: ">=", unary: false, codes: "ilfd", verbs: "performs a greater-than-or-equal ({@literal >=}) comparison on"], + [name: "LessThan", operator: "<", unary: false, codes: "ilfd", verbs: "performs a less-than ({@literal <}) comparison on"], + [name: "LessThanOrEqual", operator: "<=", unary: false, codes: "ilfd", verbs: "performs a less-than-or-equal ({@literal <=}) comparison on"], + [name: "Not", operator: "!", unary: true, codes: "b", verbs: "computes the logical NOT ({@literal !}) of"], + [name: "NotEqual", operator: "!=", unary: false, codes: "bilfd", verbs: "tests for inequality ({@literal !=}) between"], + [name: "Or", operator: "||", unary: false, codes: "b", verbs: "computes the logical OR ({@literal ||}) of"], + [name: "Xor", operator: "^", unary: false, codes: "b", verbs: "computes the logical XOR ({@literal ^}) of"] +] +``` diff --git a/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.vm b/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.vm index eb242d7a62..b250571e23 100644 --- a/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.vm +++ b/src/main/templates/net/imagej/ops/logic/PrimitiveLogic.vm @@ -1,88 +1,88 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import net.imagej.ops.AbstractOp; -import net.imagej.ops.Ops; - -import org.scijava.ItemIO; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Generated logical ops with primitive types. - * - * @author Curtis Rueden - */ -public final class PrimitiveLogic { - - private PrimitiveLogic() { - // NB: Prevent instantiation of utility class. - } -#foreach ($type in $types) -#foreach ($op in $ops) -#if ($op.codes.contains($type.code)) -#set ($iface = "Ops.Logic.$op.name") - - /** Op that $op.verbs#if ($op.unary) a $type.primitive value#else two $type.primitive values#end. */ - @Plugin(type = ${iface}.class#if ($type.priority), priority = $type.priority#end) - public static class $type.name$op.name extends AbstractOp - implements $iface - { - @Parameter(type = ItemIO.OUTPUT) - private boolean result; - - @Parameter - private $type.primitive a; -#if (!$op.unary) - - @Parameter - private $type.primitive b; -#end - - @Override - public void run() { -#if ($op.unary && $op.operator) - result = ${op.operator}a; -#elseif ($op.unary) - result = ${op.function}(a); -#elseif ($op.operator) - result = a $op.operator b; -#else - result = ${op.function}(a, b); -#end - } - } -#end -#end -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import net.imagej.ops.AbstractOp; +import net.imagej.ops.Ops; + +import org.scijava.ItemIO; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Generated logical ops with primitive types. + * + * @author Curtis Rueden + */ +public final class PrimitiveLogic { + + private PrimitiveLogic() { + // NB: Prevent instantiation of utility class. + } +#foreach ($type in $types) +#foreach ($op in $ops) +#if ($op.codes.contains($type.code)) +#set ($iface = "Ops.Logic.$op.name") + + /** Op that $op.verbs#if ($op.unary) a $type.primitive value#else two $type.primitive values#end. */ + @Plugin(type = ${iface}.class#if ($type.priority), priority = $type.priority#end) + public static class $type.name$op.name extends AbstractOp + implements $iface + { + @Parameter(type = ItemIO.OUTPUT) + private boolean result; + + @Parameter + private $type.primitive a; +#if (!$op.unary) + + @Parameter + private $type.primitive b; +#end + + @Override + public void run() { +#if ($op.unary && $op.operator) + result = ${op.operator}a; +#elseif ($op.unary) + result = ${op.function}(a); +#elseif ($op.operator) + result = a $op.operator b; +#else + result = ${op.function}(a, b); +#end + } + } +#end +#end +#end + +} diff --git a/src/main/templates/net/imagej/ops/map/MapBinaryComputers.list b/src/main/templates/net/imagej/ops/map/MapBinaryComputers.list index a79ecdf14a..bfb3bc5a00 100644 --- a/src/main/templates/net/imagej/ops/map/MapBinaryComputers.list +++ b/src/main/templates/net/imagej/ops/map/MapBinaryComputers.list @@ -1,10 +1,10 @@ -# Generate MapBinaryComputers. - -[MapBinaryComputers.java] - -types = ``` -[ - [name: "IterableInterval", alias: "II"], - [name: "RandomAccessibleInterval", alias: "RAI"], -] -``` +# Generate MapBinaryComputers. + +[MapBinaryComputers.java] + +types = ``` +[ + [name: "IterableInterval", alias: "II"], + [name: "RandomAccessibleInterval", alias: "RAI"], +] +``` diff --git a/src/main/templates/net/imagej/ops/map/MapBinaryComputers.vm b/src/main/templates/net/imagej/ops/map/MapBinaryComputers.vm index fc5e2a1139..4582534f29 100644 --- a/src/main/templates/net/imagej/ops/map/MapBinaryComputers.vm +++ b/src/main/templates/net/imagej/ops/map/MapBinaryComputers.vm @@ -1,134 +1,134 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package net.imagej.ops.map; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.Parallel; -import net.imagej.ops.thread.chunker.ChunkerOp; -import net.imagej.ops.thread.chunker.CursorBasedChunk; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccessibleInterval; - -import org.scijava.Priority; -import org.scijava.plugin.Plugin; - -/** - * Auto generated {@link MapBinaryComputer}s. - * - * @author Leon Yang - */ -public class MapBinaryComputers { - - private MapBinaryComputers() { - // NB: Prevent instantiation of utility class. - } - -#set ($priority = 7) -#foreach ($in1Type in $types) -#foreach ($in2Type in $types) -#foreach ($outType in $types) -## when $priority == 0, all types are RAI and should be skipped -#if ($priority > 0) - /** - * {@link MapBinaryComputer} from {@link $in1Type.name} and - * {@link $in2Type.name} to {@link $outType.name}. - * - * @param element type of first inputs - * @param element type of second inputs - * @param element type of outputs - */ - @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $priority) - public static class ${in1Type.alias}And${in2Type.alias}To${outType.alias} extends - AbstractMapBinaryComputer, ${in2Type.name}, ${outType.name}> - implements Contingent - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2(), out()); - } - - @Override - public void compute(final $in1Type.name input1, - final $in2Type.name input2, final $outType.name output) - { - Maps.map(input1, input2, output, getOp()); - } - } - -#set ($paraPrio = $priority + 10) - /** - * Parallelized {@link MapBinaryComputer} from {@link $in1Type.name} and - * {@link $in2Type.name} to {@link $outType.name}. - * - * @param element type of first inputs - * @param element type of second inputs - * @param element type of outputs - */ - @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $paraPrio) - public static class ${in1Type.alias}And${in2Type.alias}To${outType.alias}Parallel extends - AbstractMapBinaryComputer, ${in2Type.name}, ${outType.name}> - implements Contingent, Parallel - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2(), out()); - } - - @Override - public void compute(final $in1Type.name input1, - final $in2Type.name input2, final $outType.name output) - { - ops().run(ChunkerOp.class, new CursorBasedChunk() { - @Override - public void execute(final int startIndex, final int stepSize, - final int numSteps) - { - Maps.map(input1, input2, output, getOp().getIndependentInstance(), - startIndex, stepSize, numSteps); - } -## find the parameter with type of IterableInterval -#if ($in1Type.alias == "II") -#set ($ii = "input1") -#elseif ($in2Type.alias == "II") -#set ($ii = "input2") -#else -#set ($ii = "output") -#end - }, ${ii}.size()); - } - } - -#set ($priority = $priority - 1) -#end -#end -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imagej.ops.map; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.Parallel; +import net.imagej.ops.thread.chunker.ChunkerOp; +import net.imagej.ops.thread.chunker.CursorBasedChunk; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccessibleInterval; + +import org.scijava.Priority; +import org.scijava.plugin.Plugin; + +/** + * Auto generated {@link MapBinaryComputer}s. + * + * @author Leon Yang + */ +public class MapBinaryComputers { + + private MapBinaryComputers() { + // NB: Prevent instantiation of utility class. + } + +#set ($priority = 7) +#foreach ($in1Type in $types) +#foreach ($in2Type in $types) +#foreach ($outType in $types) +## when $priority == 0, all types are RAI and should be skipped +#if ($priority > 0) + /** + * {@link MapBinaryComputer} from {@link $in1Type.name} and + * {@link $in2Type.name} to {@link $outType.name}. + * + * @param element type of first inputs + * @param element type of second inputs + * @param element type of outputs + */ + @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $priority) + public static class ${in1Type.alias}And${in2Type.alias}To${outType.alias} extends + AbstractMapBinaryComputer, ${in2Type.name}, ${outType.name}> + implements Contingent + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2(), out()); + } + + @Override + public void compute(final $in1Type.name input1, + final $in2Type.name input2, final $outType.name output) + { + Maps.map(input1, input2, output, getOp()); + } + } + +#set ($paraPrio = $priority + 10) + /** + * Parallelized {@link MapBinaryComputer} from {@link $in1Type.name} and + * {@link $in2Type.name} to {@link $outType.name}. + * + * @param element type of first inputs + * @param element type of second inputs + * @param element type of outputs + */ + @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $paraPrio) + public static class ${in1Type.alias}And${in2Type.alias}To${outType.alias}Parallel extends + AbstractMapBinaryComputer, ${in2Type.name}, ${outType.name}> + implements Contingent, Parallel + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2(), out()); + } + + @Override + public void compute(final $in1Type.name input1, + final $in2Type.name input2, final $outType.name output) + { + ops().run(ChunkerOp.class, new CursorBasedChunk() { + @Override + public void execute(final int startIndex, final int stepSize, + final int numSteps) + { + Maps.map(input1, input2, output, getOp().getIndependentInstance(), + startIndex, stepSize, numSteps); + } +## find the parameter with type of IterableInterval +#if ($in1Type.alias == "II") +#set ($ii = "input1") +#elseif ($in2Type.alias == "II") +#set ($ii = "input2") +#else +#set ($ii = "output") +#end + }, ${ii}.size()); + } + } + +#set ($priority = $priority - 1) +#end +#end +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.list b/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.list index db0a61e757..79b7c9390e 100644 --- a/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.list +++ b/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.list @@ -1,10 +1,10 @@ -# Generate MapBinaryInplace1s. - -[MapBinaryInplace1s.java] - -types = ``` -[ - [name: "IterableInterval", alias: "II"], - [name: "RandomAccessibleInterval", alias: "RAI"], -] -``` +# Generate MapBinaryInplace1s. + +[MapBinaryInplace1s.java] + +types = ``` +[ + [name: "IterableInterval", alias: "II"], + [name: "RandomAccessibleInterval", alias: "RAI"], +] +``` diff --git a/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.vm b/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.vm index 370300f579..f853affa8d 100644 --- a/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.vm +++ b/src/main/templates/net/imagej/ops/map/MapBinaryInplace1s.vm @@ -1,126 +1,126 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package net.imagej.ops.map; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.Parallel; -import net.imagej.ops.thread.chunker.ChunkerOp; -import net.imagej.ops.thread.chunker.CursorBasedChunk; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccessibleInterval; - -import org.scijava.Priority; -import org.scijava.plugin.Plugin; - -/** - * Auto generated {@link MapBinaryInplace1}s. - * - * @author Leon Yang - */ -public class MapBinaryInplace1s { - - private MapBinaryInplace1s() { - // NB: Prevent instantiation of utility class. - } - -#set ($priority = 3) -#foreach ($argType in $types) -#foreach ($inType in $types) -## when $priority == 0, both types are RAI and should be skipped -#if ($priority > 0) - /** - * {@link MapBinaryInplace1} of {@link $argType.name} with additional input - * of {@link $inType.name}. - * - * @author Leon Yang - */ - @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $priority) - public static class ${argType.alias}And${inType.alias} extends - AbstractMapBinaryInplace1, ${inType.name}> - implements Contingent - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2()); - } - - @Override - public void mutate1(final $argType.name arg, - final $inType.name in) - { - Maps.inplace(arg, in, getOp()); - } - } - -#set ($paraPrio = $priority + 10) - /** - * Parallelized {@link MapBinaryInplace1} of {@link $argType.name} - * with additional input of {@link $inType.name}. - * - * @author Leon Yang - */ - @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $paraPrio) - public static class ${argType.alias}And${inType.alias}Parallel extends - AbstractMapBinaryInplace1, ${inType.name}> - implements Contingent, Parallel - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in1(), in2()); - } - - @Override - public void mutate1(final $argType.name arg, - final $inType.name in) - { - ops().run(ChunkerOp.class, new CursorBasedChunk() { - @Override - public void execute(final int startIndex, final int stepSize, - final int numSteps) - { - Maps.inplace(arg, in, getOp().getIndependentInstance(), - startIndex, stepSize, numSteps); - } -## find the parameter with type of IterableInterval -#if ($argType.alias == "II") -#set ($ii = "arg") -#else -#set ($ii = "in") -#end - }, ${ii}.size()); - } - } - -#set ($priority = $priority - 1) -#end -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imagej.ops.map; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.Parallel; +import net.imagej.ops.thread.chunker.ChunkerOp; +import net.imagej.ops.thread.chunker.CursorBasedChunk; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccessibleInterval; + +import org.scijava.Priority; +import org.scijava.plugin.Plugin; + +/** + * Auto generated {@link MapBinaryInplace1}s. + * + * @author Leon Yang + */ +public class MapBinaryInplace1s { + + private MapBinaryInplace1s() { + // NB: Prevent instantiation of utility class. + } + +#set ($priority = 3) +#foreach ($argType in $types) +#foreach ($inType in $types) +## when $priority == 0, both types are RAI and should be skipped +#if ($priority > 0) + /** + * {@link MapBinaryInplace1} of {@link $argType.name} with additional input + * of {@link $inType.name}. + * + * @author Leon Yang + */ + @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $priority) + public static class ${argType.alias}And${inType.alias} extends + AbstractMapBinaryInplace1, ${inType.name}> + implements Contingent + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2()); + } + + @Override + public void mutate1(final $argType.name arg, + final $inType.name in) + { + Maps.inplace(arg, in, getOp()); + } + } + +#set ($paraPrio = $priority + 10) + /** + * Parallelized {@link MapBinaryInplace1} of {@link $argType.name} + * with additional input of {@link $inType.name}. + * + * @author Leon Yang + */ + @Plugin(type = Ops.Map.class, priority = Priority.LOW_PRIORITY + $paraPrio) + public static class ${argType.alias}And${inType.alias}Parallel extends + AbstractMapBinaryInplace1, ${inType.name}> + implements Contingent, Parallel + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in1(), in2()); + } + + @Override + public void mutate1(final $argType.name arg, + final $inType.name in) + { + ops().run(ChunkerOp.class, new CursorBasedChunk() { + @Override + public void execute(final int startIndex, final int stepSize, + final int numSteps) + { + Maps.inplace(arg, in, getOp().getIndependentInstance(), + startIndex, stepSize, numSteps); + } +## find the parameter with type of IterableInterval +#if ($argType.alias == "II") +#set ($ii = "arg") +#else +#set ($ii = "in") +#end + }, ${ii}.size()); + } + } + +#set ($priority = $priority - 1) +#end +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/map/MapUnaryComputers.list b/src/main/templates/net/imagej/ops/map/MapUnaryComputers.list index 1eea6b2969..977bb55362 100644 --- a/src/main/templates/net/imagej/ops/map/MapUnaryComputers.list +++ b/src/main/templates/net/imagej/ops/map/MapUnaryComputers.list @@ -1,10 +1,10 @@ -# Generate MapUnaryComputers. - -[MapUnaryComputers.java] - -types = ``` -[ - [name: "IterableInterval", alias: "II"], - [name: "RandomAccessibleInterval", alias: "RAI"], -] -``` +# Generate MapUnaryComputers. + +[MapUnaryComputers.java] + +types = ``` +[ + [name: "IterableInterval", alias: "II"], + [name: "RandomAccessibleInterval", alias: "RAI"], +] +``` diff --git a/src/main/templates/net/imagej/ops/map/MapUnaryComputers.vm b/src/main/templates/net/imagej/ops/map/MapUnaryComputers.vm index e99388c3a7..a920ce08e1 100644 --- a/src/main/templates/net/imagej/ops/map/MapUnaryComputers.vm +++ b/src/main/templates/net/imagej/ops/map/MapUnaryComputers.vm @@ -1,129 +1,129 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ -package net.imagej.ops.map; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.Parallel; -import net.imagej.ops.thread.chunker.ChunkerOp; -import net.imagej.ops.thread.chunker.CursorBasedChunk; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccessibleInterval; - -import org.scijava.plugin.Plugin; - -/** - * Auto generated {@link MapUnaryComputer}s. - * - * @author Leon Yang - * @author Christian Dietz (University of Konstanz) - * @author Curtis Rueden - */ -public class MapUnaryComputers { - - private MapUnaryComputers() { - // NB: Prevent instantiation of utility class. - } - -#set ($priority = 3) -#foreach ($inType in $types) -#foreach ($outType in $types) -## when $priority == 0, both types are RAI and should be skipped -#if ($priority > 0) - /** - * {@link MapUnaryComputer} from {@link $inType.name} to - * {@link $outType.name}. - * - * @param element type of inputs - * @param element type of outputs - */ - @Plugin(type = Ops.Map.class, priority = $priority) - public static class ${inType.alias}To${outType.alias} extends - AbstractMapComputer, ${outType.name}> - implements Contingent - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in(), out()); - } - - @Override - public void compute(final $inType.name input, - final $outType.name output) - { - Maps.map(input, output, getOp()); - } - } - -#set ($paraPrio = $priority + 10) - /** - * Parallelized {@link MapUnaryComputer} from {@link $inType.name} to - * {@link $outType.name}. - * - * @param element type of inputs - * @param element type of outputs - */ - @Plugin(type = Ops.Map.class, priority = $paraPrio) - public static class ${inType.alias}To${outType.alias}Parallel extends - AbstractMapComputer, ${outType.name}> - implements Contingent, Parallel - { - @Override - public boolean conforms() { - return out() == null || Maps.compatible(in(), out()); - } - - @Override - public void compute(final $inType.name input, - final $outType.name output) - { - ops().run(ChunkerOp.class, new CursorBasedChunk() { - @Override - public void execute(final int startIndex, final int stepSize, - final int numSteps) - { - Maps.map(input, output, getOp().getIndependentInstance(), - startIndex, stepSize, numSteps); - } -## find the parameter with type of IterableInterval -#if ($inType.alias == "II") -#set ($ii = "input") -#else -#set ($ii = "output") -#end - }, ${ii}.size()); - } - } - -#set ($priority = $priority - 1) -#end -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ +package net.imagej.ops.map; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.Parallel; +import net.imagej.ops.thread.chunker.ChunkerOp; +import net.imagej.ops.thread.chunker.CursorBasedChunk; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccessibleInterval; + +import org.scijava.plugin.Plugin; + +/** + * Auto generated {@link MapUnaryComputer}s. + * + * @author Leon Yang + * @author Christian Dietz (University of Konstanz) + * @author Curtis Rueden + */ +public class MapUnaryComputers { + + private MapUnaryComputers() { + // NB: Prevent instantiation of utility class. + } + +#set ($priority = 3) +#foreach ($inType in $types) +#foreach ($outType in $types) +## when $priority == 0, both types are RAI and should be skipped +#if ($priority > 0) + /** + * {@link MapUnaryComputer} from {@link $inType.name} to + * {@link $outType.name}. + * + * @param element type of inputs + * @param element type of outputs + */ + @Plugin(type = Ops.Map.class, priority = $priority) + public static class ${inType.alias}To${outType.alias} extends + AbstractMapComputer, ${outType.name}> + implements Contingent + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in(), out()); + } + + @Override + public void compute(final $inType.name input, + final $outType.name output) + { + Maps.map(input, output, getOp()); + } + } + +#set ($paraPrio = $priority + 10) + /** + * Parallelized {@link MapUnaryComputer} from {@link $inType.name} to + * {@link $outType.name}. + * + * @param element type of inputs + * @param element type of outputs + */ + @Plugin(type = Ops.Map.class, priority = $paraPrio) + public static class ${inType.alias}To${outType.alias}Parallel extends + AbstractMapComputer, ${outType.name}> + implements Contingent, Parallel + { + @Override + public boolean conforms() { + return out() == null || Maps.compatible(in(), out()); + } + + @Override + public void compute(final $inType.name input, + final $outType.name output) + { + ops().run(ChunkerOp.class, new CursorBasedChunk() { + @Override + public void execute(final int startIndex, final int stepSize, + final int numSteps) + { + Maps.map(input, output, getOp().getIndependentInstance(), + startIndex, stepSize, numSteps); + } +## find the parameter with type of IterableInterval +#if ($inType.alias == "II") +#set ($ii = "input") +#else +#set ($ii = "output") +#end + }, ${ii}.size()); + } + } + +#set ($priority = $priority - 1) +#end +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.list b/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.list index dbf27d3b97..142e771d01 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.list +++ b/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.list @@ -1,27 +1,27 @@ -# Generated binary arithmetic ops with ArrayImages. - -[ConstantToArrayImage.java] - -types = ``` -[ - [name: "Byte", array: "Byte", primitive: "byte"], - [name: "Int", array: "Int", primitive: "int"], - [name: "Long", array: "Long", primitive: "long"], - [name: "Short", array: "Short", primitive: "short"], - [name: "Float", array: "Float", primitive: "float"], - [name: "Double", array: "Double", primitive: "double"], - [name: "UnsignedByte", array: "Byte", primitive: "byte"], - [name: "UnsignedInt", array: "Int", primitive: "int"], - [name: "UnsignedLong", array: "Long", primitive: "long"], - [name: "UnsignedShort",array: "Short", primitive: "short"] -] -``` - -ops = ``` -[ - [name: "Add", operator: "+"], - [name: "Subtract", operator: "-"], - [name: "Multiply", operator: "*"], - [name: "Divide", operator: "/"] -] -``` +# Generated binary arithmetic ops with ArrayImages. + +[ConstantToArrayImage.java] + +types = ``` +[ + [name: "Byte", array: "Byte", primitive: "byte"], + [name: "Int", array: "Int", primitive: "int"], + [name: "Long", array: "Long", primitive: "long"], + [name: "Short", array: "Short", primitive: "short"], + [name: "Float", array: "Float", primitive: "float"], + [name: "Double", array: "Double", primitive: "double"], + [name: "UnsignedByte", array: "Byte", primitive: "byte"], + [name: "UnsignedInt", array: "Int", primitive: "int"], + [name: "UnsignedLong", array: "Long", primitive: "long"], + [name: "UnsignedShort",array: "Short", primitive: "short"] +] +``` + +ops = ``` +[ + [name: "Add", operator: "+"], + [name: "Subtract", operator: "-"], + [name: "Multiply", operator: "*"], + [name: "Divide", operator: "/"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.vm b/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.vm index 7b900d66d1..a57104c2d3 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.vm +++ b/src/main/templates/net/imagej/ops/math/ConstantToArrayImage.vm @@ -1,103 +1,103 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; -import net.imglib2.img.array.ArrayImg; -import net.imglib2.img.basictypeaccess.array.ByteArray; -import net.imglib2.img.basictypeaccess.array.DoubleArray; -import net.imglib2.img.basictypeaccess.array.FloatArray; -import net.imglib2.img.basictypeaccess.array.IntArray; -import net.imglib2.img.basictypeaccess.array.LongArray; -import net.imglib2.img.basictypeaccess.array.ShortArray; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.integer.ShortType; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.type.numeric.integer.UnsignedIntType; -import net.imglib2.type.numeric.integer.UnsignedLongType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.scijava.Priority; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary math operations between constant values and {@link ArrayImg}s. - *

- * Add, subtract, multiply, and divide are implemented for {@link ArrayImg}s - * of {@link ByteType} or {@link DoubleType}. - *

- * - * @author Leon Yang - */ -public final class ConstantToArrayImage { - private ConstantToArrayImage() { - // NB: Prevent instantiation of utility class. - } -#foreach ($type in $types) -#set ($imgType = "ArrayImg<${type.name}Type, ${type.array}Array>") -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) - public static class ${op.name}${type.name} extends - AbstractUnaryInplaceOp<$imgType> implements Contingent, - $iface - { - - @Parameter - private ${type.primitive} value; - - @Override - public void mutate(final $imgType arg) { - final ${type.primitive}[] data = arg.update(null).getCurrentStorageArray(); - for (int i = 0; i < data.length; i++) { - data[i] ${op.operator}= value; - } - } - - @Override - public boolean conforms() { - // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. - // The warning is expected, because the image parameter is assigned via - // reflection and hence might not match the declared generic types. - return in().firstElement() instanceof ${type.name}Type; - } - } -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; +import net.imglib2.img.array.ArrayImg; +import net.imglib2.img.basictypeaccess.array.ByteArray; +import net.imglib2.img.basictypeaccess.array.DoubleArray; +import net.imglib2.img.basictypeaccess.array.FloatArray; +import net.imglib2.img.basictypeaccess.array.IntArray; +import net.imglib2.img.basictypeaccess.array.LongArray; +import net.imglib2.img.basictypeaccess.array.ShortArray; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedLongType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.scijava.Priority; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary math operations between constant values and {@link ArrayImg}s. + *

+ * Add, subtract, multiply, and divide are implemented for {@link ArrayImg}s + * of {@link ByteType} or {@link DoubleType}. + *

+ * + * @author Leon Yang + */ +public final class ConstantToArrayImage { + private ConstantToArrayImage() { + // NB: Prevent instantiation of utility class. + } +#foreach ($type in $types) +#set ($imgType = "ArrayImg<${type.name}Type, ${type.array}Array>") +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) + public static class ${op.name}${type.name} extends + AbstractUnaryInplaceOp<$imgType> implements Contingent, + $iface + { + + @Parameter + private ${type.primitive} value; + + @Override + public void mutate(final $imgType arg) { + final ${type.primitive}[] data = arg.update(null).getCurrentStorageArray(); + for (int i = 0; i < data.length; i++) { + data[i] ${op.operator}= value; + } + } + + @Override + public boolean conforms() { + // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. + // The warning is expected, because the image parameter is assigned via + // reflection and hence might not match the declared generic types. + return in().firstElement() instanceof ${type.name}Type; + } + } +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.list b/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.list index df24eb3c25..2ee452bdc2 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.list +++ b/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.list @@ -1,27 +1,27 @@ -# Generated multi-threaded version of binary arithmetic ops with ArrayImages. - -[ConstantToArrayImageP.java] - -types = ``` -[ - [name: "Byte", array: "Byte", primitive: "byte"], - [name: "Int", array: "Int", primitive: "int"], - [name: "Long", array: "Long", primitive: "long"], - [name: "Short", array: "Short", primitive: "short"], - [name: "Float", array: "Float", primitive: "float"], - [name: "Double", array: "Double", primitive: "double"], - [name: "UnsignedByte", array: "Byte", primitive: "byte"], - [name: "UnsignedInt", array: "Int", primitive: "int"], - [name: "UnsignedLong", array: "Long", primitive: "long"], - [name: "UnsignedShort",array: "Short", primitive: "short"] -] -``` - -ops = ``` -[ - [name: "Add", operator: "+", verb: "add constant for"], - [name: "Subtract", operator: "-", verb: "subtract constant from"], - [name: "Multiply", operator: "*", verb: "multiply constant for"], - [name: "Divide", operator: "/", verb: "divide constant from"] -] -``` +# Generated multi-threaded version of binary arithmetic ops with ArrayImages. + +[ConstantToArrayImageP.java] + +types = ``` +[ + [name: "Byte", array: "Byte", primitive: "byte"], + [name: "Int", array: "Int", primitive: "int"], + [name: "Long", array: "Long", primitive: "long"], + [name: "Short", array: "Short", primitive: "short"], + [name: "Float", array: "Float", primitive: "float"], + [name: "Double", array: "Double", primitive: "double"], + [name: "UnsignedByte", array: "Byte", primitive: "byte"], + [name: "UnsignedInt", array: "Int", primitive: "int"], + [name: "UnsignedLong", array: "Long", primitive: "long"], + [name: "UnsignedShort",array: "Short", primitive: "short"] +] +``` + +ops = ``` +[ + [name: "Add", operator: "+", verb: "add constant for"], + [name: "Subtract", operator: "-", verb: "subtract constant from"], + [name: "Multiply", operator: "*", verb: "multiply constant for"], + [name: "Divide", operator: "/", verb: "divide constant from"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.vm b/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.vm index 21ae7c8c85..2137b7f702 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.vm +++ b/src/main/templates/net/imagej/ops/math/ConstantToArrayImageP.vm @@ -1,127 +1,127 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; -import net.imagej.ops.thread.chunker.Chunk; -import net.imagej.ops.thread.chunker.ChunkerOp; -import net.imglib2.img.array.ArrayImg; -import net.imglib2.img.basictypeaccess.array.ByteArray; -import net.imglib2.img.basictypeaccess.array.DoubleArray; -import net.imglib2.img.basictypeaccess.array.FloatArray; -import net.imglib2.img.basictypeaccess.array.IntArray; -import net.imglib2.img.basictypeaccess.array.LongArray; -import net.imglib2.img.basictypeaccess.array.ShortArray; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.integer.ShortType; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.type.numeric.integer.UnsignedIntType; -import net.imglib2.type.numeric.integer.UnsignedLongType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.scijava.Priority; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for multi-threaded version of binary math operations between - * constant values and {@link ArrayImg}s. - *

- * Add, subtract, multiply, and divide are implemented for {@link ArrayImg}s - * of {@link ByteType} or {@link DoubleType}. - *

- * - * @author Leon Yang - */ -public final class ConstantToArrayImageP { - - private ConstantToArrayImageP() { - // NB: Prevent instantiation of utility class. - } -#foreach ($type in $types) -#set ($imgType = "ArrayImg<${type.name}Type, ${type.array}Array>") -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - /** - * Multi-threaded version of optimized $op.verb {@link ArrayImg}s of - * type {@link ${type.name}Type} - * - * @author Christian Dietz (University of Konstanz) - */ - @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY + 1) - public static class ${op.name}${type.name} extends - AbstractUnaryInplaceOp<$imgType> implements Contingent, - $iface - { - - @Parameter - private ${type.primitive} value; - - @Override - public void mutate(final $imgType arg) { - final ${type.primitive}[] data = arg.update(null).getCurrentStorageArray(); - ops().run(ChunkerOp.class, new Chunk() { - - @Override - public void execute(final int startIndex, final int stepSize, - final int numSteps) { - if (stepSize != 1) { - for (int i = startIndex, j = 0; j < numSteps; i = i - + stepSize, j++) { - data[i] ${op.operator}= value; - } - } else { - for (int i = startIndex; i < startIndex + numSteps; i++) { - data[i] ${op.operator}= value; - } - } - } - }, data.length); - } - - @Override - public boolean conforms() { - // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. - // The warning is expected, because the image parameter is assigned via - // reflection and hence might not match the declared generic types. - return in().firstElement() instanceof ${type.name}Type; - } - } -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; +import net.imagej.ops.thread.chunker.Chunk; +import net.imagej.ops.thread.chunker.ChunkerOp; +import net.imglib2.img.array.ArrayImg; +import net.imglib2.img.basictypeaccess.array.ByteArray; +import net.imglib2.img.basictypeaccess.array.DoubleArray; +import net.imglib2.img.basictypeaccess.array.FloatArray; +import net.imglib2.img.basictypeaccess.array.IntArray; +import net.imglib2.img.basictypeaccess.array.LongArray; +import net.imglib2.img.basictypeaccess.array.ShortArray; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedLongType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.scijava.Priority; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for multi-threaded version of binary math operations between + * constant values and {@link ArrayImg}s. + *

+ * Add, subtract, multiply, and divide are implemented for {@link ArrayImg}s + * of {@link ByteType} or {@link DoubleType}. + *

+ * + * @author Leon Yang + */ +public final class ConstantToArrayImageP { + + private ConstantToArrayImageP() { + // NB: Prevent instantiation of utility class. + } +#foreach ($type in $types) +#set ($imgType = "ArrayImg<${type.name}Type, ${type.array}Array>") +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + /** + * Multi-threaded version of optimized $op.verb {@link ArrayImg}s of + * type {@link ${type.name}Type} + * + * @author Christian Dietz (University of Konstanz) + */ + @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY + 1) + public static class ${op.name}${type.name} extends + AbstractUnaryInplaceOp<$imgType> implements Contingent, + $iface + { + + @Parameter + private ${type.primitive} value; + + @Override + public void mutate(final $imgType arg) { + final ${type.primitive}[] data = arg.update(null).getCurrentStorageArray(); + ops().run(ChunkerOp.class, new Chunk() { + + @Override + public void execute(final int startIndex, final int stepSize, + final int numSteps) { + if (stepSize != 1) { + for (int i = startIndex, j = 0; j < numSteps; i = i + + stepSize, j++) { + data[i] ${op.operator}= value; + } + } else { + for (int i = startIndex; i < startIndex + numSteps; i++) { + data[i] ${op.operator}= value; + } + } + } + }, data.length); + } + + @Override + public boolean conforms() { + // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. + // The warning is expected, because the image parameter is assigned via + // reflection and hence might not match the declared generic types. + return in().firstElement() instanceof ${type.name}Type; + } + } +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.list b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.list index a858d2e32c..34eac669e3 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.list +++ b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.list @@ -1,12 +1,12 @@ -# Generated functional binary arithmetic ops with II as both input and output. - -[ConstantToIIOutputII.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Generated functional binary arithmetic ops with II as both input and output. + +[ConstantToIIOutputII.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.vm b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.vm index 01e05b82b3..7400567a2e 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.vm +++ b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputII.vm @@ -1,115 +1,115 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.function.Functions; -import net.imagej.ops.special.function.UnaryFunctionOp; -import net.imagej.ops.special.hybrid.AbstractUnaryHybridCFI; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.type.numeric.NumericType; - -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for functional binary math operations between constant values - * and {@link IterableInterval}s, and write the result - * to {@link IterableInterval}s. - * - * @author Leon Yang - */ -public final class ConstantToIIOutputII { - - private ConstantToIIOutputII() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class) - public static class ${op.name}> extends - AbstractUnaryHybridCFI, IterableInterval> - implements Contingent, $iface - { - - @Parameter - private T value; - - private UnaryFunctionOp, IterableInterval> outputCreator; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void initialize() { - outputCreator = (UnaryFunctionOp) Functions.unary(ops(), - Ops.Create.Img.class, IterableInterval.class, in(), in().firstElement() - .createVariable()); - } - - @Override - public void compute(final IterableInterval input, - final IterableInterval output) - { - final Cursor inCursor = input.cursor(); - final Cursor outCursor = output.cursor(); - while (inCursor.hasNext()) { - outCursor.next().set(inCursor.next()); - outCursor.get().${op.function}(value); - } - } - - @Override - public IterableInterval createOutput(final IterableInterval input) { - return outputCreator.calculate(input); - } - - @Override - public boolean conforms() { - if (out() == null) return true; - return in().iterationOrder().equals(out().iterationOrder()); - } - - @Override - public void mutate(final IterableInterval arg) { - for (final T t : arg) { - t.${op.function}(value); - } - } - - @Override - public ${op.name} getIndependentInstance() { - return this; - } - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.function.Functions; +import net.imagej.ops.special.function.UnaryFunctionOp; +import net.imagej.ops.special.hybrid.AbstractUnaryHybridCFI; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.type.numeric.NumericType; + +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for functional binary math operations between constant values + * and {@link IterableInterval}s, and write the result + * to {@link IterableInterval}s. + * + * @author Leon Yang + */ +public final class ConstantToIIOutputII { + + private ConstantToIIOutputII() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class) + public static class ${op.name}> extends + AbstractUnaryHybridCFI, IterableInterval> + implements Contingent, $iface + { + + @Parameter + private T value; + + private UnaryFunctionOp, IterableInterval> outputCreator; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void initialize() { + outputCreator = (UnaryFunctionOp) Functions.unary(ops(), + Ops.Create.Img.class, IterableInterval.class, in(), in().firstElement() + .createVariable()); + } + + @Override + public void compute(final IterableInterval input, + final IterableInterval output) + { + final Cursor inCursor = input.cursor(); + final Cursor outCursor = output.cursor(); + while (inCursor.hasNext()) { + outCursor.next().set(inCursor.next()); + outCursor.get().${op.function}(value); + } + } + + @Override + public IterableInterval createOutput(final IterableInterval input) { + return outputCreator.calculate(input); + } + + @Override + public boolean conforms() { + if (out() == null) return true; + return in().iterationOrder().equals(out().iterationOrder()); + } + + @Override + public void mutate(final IterableInterval arg) { + for (final T t : arg) { + t.${op.function}(value); + } + } + + @Override + public ${op.name} getIndependentInstance() { + return this; + } + } +#end +} diff --git a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.list b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.list index c6cea1c1de..6dbf0ed40d 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.list +++ b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.list @@ -1,12 +1,12 @@ -# Generated functional binary arithmetic ops with II as input and RAI as output. - -[ConstantToIIOutputRAI.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Generated functional binary arithmetic ops with II as input and RAI as output. + +[ConstantToIIOutputRAI.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.vm b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.vm index a0492db2ad..873c65a4f0 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.vm +++ b/src/main/templates/net/imagej/ops/math/ConstantToIIOutputRAI.vm @@ -1,84 +1,84 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Ops; -import net.imagej.ops.special.computer.AbstractUnaryComputerOp; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccess; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.type.numeric.NumericType; - -import org.scijava.Priority; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for functional binary math operations between constant values - * and {@link IterableInterval}s, and write the result - * to {@link RandomAccessibleInterval}s. - * - * @author Leon Yang - */ -public final class ConstantToIIOutputRAI { - - private ConstantToIIOutputRAI() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class, priority = Priority.VERY_LOW_PRIORITY) - public static class ${op.name}> extends - AbstractUnaryComputerOp, RandomAccessibleInterval> - implements ${iface} { - - @Parameter - private T value; - - @Override - public void compute(final IterableInterval input, - final RandomAccessibleInterval output) { - final Cursor c = input.localizingCursor(); - final RandomAccess ra = output.randomAccess(); - while (c.hasNext()) { - final T in = c.next(); - ra.setPosition(c); - final T out = ra.get(); - out.set(in); - out.${op.function}(value); - } - } - - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Ops; +import net.imagej.ops.special.computer.AbstractUnaryComputerOp; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccess; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.type.numeric.NumericType; + +import org.scijava.Priority; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for functional binary math operations between constant values + * and {@link IterableInterval}s, and write the result + * to {@link RandomAccessibleInterval}s. + * + * @author Leon Yang + */ +public final class ConstantToIIOutputRAI { + + private ConstantToIIOutputRAI() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class, priority = Priority.VERY_LOW_PRIORITY) + public static class ${op.name}> extends + AbstractUnaryComputerOp, RandomAccessibleInterval> + implements ${iface} { + + @Parameter + private T value; + + @Override + public void compute(final IterableInterval input, + final RandomAccessibleInterval output) { + final Cursor c = input.localizingCursor(); + final RandomAccess ra = output.randomAccess(); + while (c.hasNext()) { + final T in = c.next(); + ra.setPosition(c); + final T out = ra.get(); + out.set(in); + out.${op.function}(value); + } + } + + } +#end +} diff --git a/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.list b/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.list index 0e97c86bb3..269313391f 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.list +++ b/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.list @@ -1,27 +1,27 @@ -# Generated binary arithmetic ops with PlanarImages. - -[ConstantToPlanarImage.java] - -types = ``` -[ - [name: "Byte", array: "Byte", primitive: "byte"], - [name: "Int", array: "Int", primitive: "int"], - [name: "Long", array: "Long", primitive: "long"], - [name: "Short", array: "Short", primitive: "short"], - [name: "Float", array: "Float", primitive: "float"], - [name: "Double", array: "Double", primitive: "double"], - [name: "UnsignedByte", array: "Byte", primitive: "byte"], - [name: "UnsignedInt", array: "Int", primitive: "int"], - [name: "UnsignedLong", array: "Long", primitive: "long"], - [name: "UnsignedShort",array: "Short", primitive: "short"] -] -``` - -ops = ``` -[ - [name: "Add", operator: "+"], - [name: "Subtract", operator: "-"], - [name: "Multiply", operator: "*"], - [name: "Divide", operator: "/"], -] -``` +# Generated binary arithmetic ops with PlanarImages. + +[ConstantToPlanarImage.java] + +types = ``` +[ + [name: "Byte", array: "Byte", primitive: "byte"], + [name: "Int", array: "Int", primitive: "int"], + [name: "Long", array: "Long", primitive: "long"], + [name: "Short", array: "Short", primitive: "short"], + [name: "Float", array: "Float", primitive: "float"], + [name: "Double", array: "Double", primitive: "double"], + [name: "UnsignedByte", array: "Byte", primitive: "byte"], + [name: "UnsignedInt", array: "Int", primitive: "int"], + [name: "UnsignedLong", array: "Long", primitive: "long"], + [name: "UnsignedShort",array: "Short", primitive: "short"] +] +``` + +ops = ``` +[ + [name: "Add", operator: "+"], + [name: "Subtract", operator: "-"], + [name: "Multiply", operator: "*"], + [name: "Divide", operator: "/"], +] +``` diff --git a/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.vm b/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.vm index f08f1f2d81..bde5461889 100644 --- a/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.vm +++ b/src/main/templates/net/imagej/ops/math/ConstantToPlanarImage.vm @@ -1,110 +1,110 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; -import net.imglib2.img.basictypeaccess.array.ByteArray; -import net.imglib2.img.basictypeaccess.array.DoubleArray; -import net.imglib2.img.basictypeaccess.array.FloatArray; -import net.imglib2.img.basictypeaccess.array.IntArray; -import net.imglib2.img.basictypeaccess.array.LongArray; -import net.imglib2.img.basictypeaccess.array.ShortArray; -import net.imglib2.img.planar.PlanarImg; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.integer.ShortType; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.type.numeric.integer.UnsignedIntType; -import net.imglib2.type.numeric.integer.UnsignedLongType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary math operations between constant values and {@link PlanarImg}s. - *

- * Add, subtract, multiply, and divide are implemented for {@link PlanarImg}s - * of {@link DoubleType}. - *

- * - * @author Leon Yang - */ -public final class ConstantToPlanarImage { - - private ConstantToPlanarImage() { - // NB: Prevent instantiation of utility class. - } -#foreach ($type in $types) -#set ($imgType = "PlanarImg<${type.name}Type, ${type.array}Array>") -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class) - public static class ${op.name}${type.name} extends - AbstractUnaryInplaceOp<$imgType> implements $iface, - Contingent - { - - @Parameter - private ${type.primitive} value; - - @Override - public void mutate(final $imgType arg) { - long planeCount = 1; - for (int d = 2; d < arg.numDimensions(); d++) { - planeCount *= arg.dimension(d); - } - for (int p = 0; p < planeCount; p++) { - final ${type.primitive}[] plane = arg.getPlane(p).getCurrentStorageArray(); - for (int i = 0; i < plane.length; i++) { - plane[i] ${op.operator}= value; - } - } - } - - @Override - public boolean conforms() { - // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. - // The warning is expected, because the image parameter is assigned via - // reflection and hence might not match the declared generic types. - return in().firstElement() instanceof ${type.name}Type; - } - - } -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.inplace.AbstractUnaryInplaceOp; +import net.imglib2.img.basictypeaccess.array.ByteArray; +import net.imglib2.img.basictypeaccess.array.DoubleArray; +import net.imglib2.img.basictypeaccess.array.FloatArray; +import net.imglib2.img.basictypeaccess.array.IntArray; +import net.imglib2.img.basictypeaccess.array.LongArray; +import net.imglib2.img.basictypeaccess.array.ShortArray; +import net.imglib2.img.planar.PlanarImg; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedLongType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary math operations between constant values and {@link PlanarImg}s. + *

+ * Add, subtract, multiply, and divide are implemented for {@link PlanarImg}s + * of {@link DoubleType}. + *

+ * + * @author Leon Yang + */ +public final class ConstantToPlanarImage { + + private ConstantToPlanarImage() { + // NB: Prevent instantiation of utility class. + } +#foreach ($type in $types) +#set ($imgType = "PlanarImg<${type.name}Type, ${type.array}Array>") +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class) + public static class ${op.name}${type.name} extends + AbstractUnaryInplaceOp<$imgType> implements $iface, + Contingent + { + + @Parameter + private ${type.primitive} value; + + @Override + public void mutate(final $imgType arg) { + long planeCount = 1; + for (int d = 2; d < arg.numDimensions(); d++) { + planeCount *= arg.dimension(d); + } + for (int p = 0; p < planeCount; p++) { + final ${type.primitive}[] plane = arg.getPlane(p).getCurrentStorageArray(); + for (int i = 0; i < plane.length; i++) { + plane[i] ${op.operator}= value; + } + } + } + + @Override + public boolean conforms() { + // NB: Until https://github.com/imagej/imagej-ops/issues/95 is addressed. + // The warning is expected, because the image parameter is assigned via + // reflection and hence might not match the declared generic types. + return in().firstElement() instanceof ${type.name}Type; + } + + } +#end +#end +} diff --git a/src/main/templates/net/imagej/ops/math/IIToIIOutputII.list b/src/main/templates/net/imagej/ops/math/IIToIIOutputII.list index 20de0c275c..a2a612eed7 100644 --- a/src/main/templates/net/imagej/ops/math/IIToIIOutputII.list +++ b/src/main/templates/net/imagej/ops/math/IIToIIOutputII.list @@ -1,13 +1,13 @@ -# Generated binary arithmetic ops with IterableIntervals and output to -# IterableIntervals. - -[IIToIIOutputII.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Generated binary arithmetic ops with IterableIntervals and output to +# IterableIntervals. + +[IIToIIOutputII.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/IIToIIOutputII.vm b/src/main/templates/net/imagej/ops/math/IIToIIOutputII.vm index 57ad95dbfe..17a87c5751 100644 --- a/src/main/templates/net/imagej/ops/math/IIToIIOutputII.vm +++ b/src/main/templates/net/imagej/ops/math/IIToIIOutputII.vm @@ -1,139 +1,139 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.function.Functions; -import net.imagej.ops.special.function.UnaryFunctionOp; -import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.type.numeric.NumericType; -import net.imglib2.util.Intervals; - -import org.scijava.Priority; -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary math operations between {@link IterableInterval}s - * and write result to {@link IterableInterval}s. - * - * @author Leon Yang - */ -public final class IIToIIOutputII { - - private IIToIIOutputII() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) - public static class ${op.name}> extends - AbstractBinaryHybridCFI, IterableInterval> - implements $iface, Contingent - { - - private UnaryFunctionOp, IterableInterval> outputCreator; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void initialize() { - outputCreator = (UnaryFunctionOp) Functions.unary(ops(), - Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() - .createVariable()); - } - - // TODO: extend common abstract base class which implements Contingent - // for dimensionality checking. - - @Override - public boolean conforms() { - if (!Intervals.equalDimensions(in1(), in2())) return false; - if (!in1().iterationOrder().equals(in2().iterationOrder())) return false; - if (out() == null) return true; - return Intervals.equalDimensions(in1(), out()) && in1().iterationOrder() - .equals(out().iterationOrder()); - } - - @Override - public IterableInterval createOutput(final IterableInterval input1, - final IterableInterval input2) - { - return outputCreator.calculate(input1); - } - - @Override - public void compute(final IterableInterval input1, - final IterableInterval input2, final IterableInterval output) - { - final Cursor in1Cursor = input1.cursor(); - final Cursor in2Cursor = input2.cursor(); - final Cursor outCursor = output.cursor(); - while (in1Cursor.hasNext()) { - outCursor.next().set(in1Cursor.next()); - outCursor.get().${op.function}(in2Cursor.next()); - } - } - - @Override - public void mutate1(final IterableInterval arg, - final IterableInterval in) - { - final Cursor in1Cursor = arg.cursor(); - final Cursor in2Cursor = in.cursor(); - while (in1Cursor.hasNext()) { - in1Cursor.next().${op.function}(in2Cursor.next()); - } - } - - @Override - public void mutate2(final IterableInterval in, - final IterableInterval arg) - { - final T tmp = in.firstElement().createVariable(); - final Cursor in1Cursor = in.cursor(); - final Cursor in2Cursor = arg.cursor(); - while (in1Cursor.hasNext()) { - tmp.set(in1Cursor.next()); - tmp.${op.function}(in2Cursor.next()); - in2Cursor.get().set(tmp); - } - } - - @Override - public ${op.name} getIndependentInstance() { - return this; - } - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.function.Functions; +import net.imagej.ops.special.function.UnaryFunctionOp; +import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.type.numeric.NumericType; +import net.imglib2.util.Intervals; + +import org.scijava.Priority; +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary math operations between {@link IterableInterval}s + * and write result to {@link IterableInterval}s. + * + * @author Leon Yang + */ +public final class IIToIIOutputII { + + private IIToIIOutputII() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) + public static class ${op.name}> extends + AbstractBinaryHybridCFI, IterableInterval> + implements $iface, Contingent + { + + private UnaryFunctionOp, IterableInterval> outputCreator; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void initialize() { + outputCreator = (UnaryFunctionOp) Functions.unary(ops(), + Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() + .createVariable()); + } + + // TODO: extend common abstract base class which implements Contingent + // for dimensionality checking. + + @Override + public boolean conforms() { + if (!Intervals.equalDimensions(in1(), in2())) return false; + if (!in1().iterationOrder().equals(in2().iterationOrder())) return false; + if (out() == null) return true; + return Intervals.equalDimensions(in1(), out()) && in1().iterationOrder() + .equals(out().iterationOrder()); + } + + @Override + public IterableInterval createOutput(final IterableInterval input1, + final IterableInterval input2) + { + return outputCreator.calculate(input1); + } + + @Override + public void compute(final IterableInterval input1, + final IterableInterval input2, final IterableInterval output) + { + final Cursor in1Cursor = input1.cursor(); + final Cursor in2Cursor = input2.cursor(); + final Cursor outCursor = output.cursor(); + while (in1Cursor.hasNext()) { + outCursor.next().set(in1Cursor.next()); + outCursor.get().${op.function}(in2Cursor.next()); + } + } + + @Override + public void mutate1(final IterableInterval arg, + final IterableInterval in) + { + final Cursor in1Cursor = arg.cursor(); + final Cursor in2Cursor = in.cursor(); + while (in1Cursor.hasNext()) { + in1Cursor.next().${op.function}(in2Cursor.next()); + } + } + + @Override + public void mutate2(final IterableInterval in, + final IterableInterval arg) + { + final T tmp = in.firstElement().createVariable(); + final Cursor in1Cursor = in.cursor(); + final Cursor in2Cursor = arg.cursor(); + while (in1Cursor.hasNext()) { + tmp.set(in1Cursor.next()); + tmp.${op.function}(in2Cursor.next()); + in2Cursor.get().set(tmp); + } + } + + @Override + public ${op.name} getIndependentInstance() { + return this; + } + } +#end +} diff --git a/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.list b/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.list index ec33b53424..c67485650a 100644 --- a/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.list +++ b/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.list @@ -1,13 +1,13 @@ -# Generated binary arithmetic ops with IterableIntervals and -# RandomAccessibleIntervals, and output to IterableIntervals. - -[IIToRAIOutputII.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Generated binary arithmetic ops with IterableIntervals and +# RandomAccessibleIntervals, and output to IterableIntervals. + +[IIToRAIOutputII.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.vm b/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.vm index 13ff53f602..8da648d0ff 100644 --- a/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.vm +++ b/src/main/templates/net/imagej/ops/math/IIToRAIOutputII.vm @@ -1,130 +1,130 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.function.Functions; -import net.imagej.ops.special.function.UnaryFunctionOp; -import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.RandomAccess; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.type.numeric.NumericType; -import net.imglib2.util.Intervals; - -import org.scijava.plugin.Plugin; - -/** - * Wrapper class for binary math operations between {@link IterableInterval}s - * and {@link RandomAccessibleInterval}s, and writes the result to - * {@link IterableInterval}s. - * - * @author Leon Yang - */ -public final class IIToRAIOutputII { - - private IIToRAIOutputII() { - // NB: Prevent instantiation of utility class. - } -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - @Plugin(type = ${iface}.class) - public static class ${op.name}> extends - AbstractBinaryHybridCFI1, RandomAccessibleInterval, IterableInterval> - implements $iface, Contingent - { - - private UnaryFunctionOp, IterableInterval> outputCreator; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public void initialize() { - outputCreator = (UnaryFunctionOp) Functions.unary(ops(), - Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() - .createVariable()); - } - - // TODO: extend common abstract base class which implements Contingent - // for dimensionality checking. - - @Override - public boolean conforms() { - if (!Intervals.equalDimensions(in1(), in2())) return false; - if (out() == null) return true; - return Intervals.equalDimensions(in1(), out()) && in1().iterationOrder() - .equals(out().iterationOrder()); - } - - @Override - public IterableInterval createOutput(final IterableInterval input1, - final RandomAccessibleInterval input2) - { - return outputCreator.calculate(input1); - } - - @Override - public void compute(final IterableInterval input1, - final RandomAccessibleInterval input2, - final IterableInterval output) - { - final Cursor in1Cursor = input1.localizingCursor(); - final RandomAccess in2Access = input2.randomAccess(); - final Cursor outCursor = output.cursor(); - while (in1Cursor.hasNext()) { - outCursor.next().set(in1Cursor.next()); - in2Access.setPosition(in1Cursor); - outCursor.get().${op.function}(in2Access.get()); - } - } - - @Override - public void mutate1(final IterableInterval arg, - final RandomAccessibleInterval in) - { - final Cursor in1Cursor = arg.localizingCursor(); - final RandomAccess in2Access = in.randomAccess(); - while (in1Cursor.hasNext()) { - in1Cursor.fwd(); - in2Access.setPosition(in1Cursor); - in1Cursor.get().${op.function}(in2Access.get()); - } - } - - @Override - public ${op.name} getIndependentInstance() { - return this; - } - } -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.function.Functions; +import net.imagej.ops.special.function.UnaryFunctionOp; +import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI1; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.RandomAccess; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.type.numeric.NumericType; +import net.imglib2.util.Intervals; + +import org.scijava.plugin.Plugin; + +/** + * Wrapper class for binary math operations between {@link IterableInterval}s + * and {@link RandomAccessibleInterval}s, and writes the result to + * {@link IterableInterval}s. + * + * @author Leon Yang + */ +public final class IIToRAIOutputII { + + private IIToRAIOutputII() { + // NB: Prevent instantiation of utility class. + } +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + @Plugin(type = ${iface}.class) + public static class ${op.name}> extends + AbstractBinaryHybridCFI1, RandomAccessibleInterval, IterableInterval> + implements $iface, Contingent + { + + private UnaryFunctionOp, IterableInterval> outputCreator; + + @SuppressWarnings({ "unchecked", "rawtypes" }) + @Override + public void initialize() { + outputCreator = (UnaryFunctionOp) Functions.unary(ops(), + Ops.Create.Img.class, IterableInterval.class, in1(), in1().firstElement() + .createVariable()); + } + + // TODO: extend common abstract base class which implements Contingent + // for dimensionality checking. + + @Override + public boolean conforms() { + if (!Intervals.equalDimensions(in1(), in2())) return false; + if (out() == null) return true; + return Intervals.equalDimensions(in1(), out()) && in1().iterationOrder() + .equals(out().iterationOrder()); + } + + @Override + public IterableInterval createOutput(final IterableInterval input1, + final RandomAccessibleInterval input2) + { + return outputCreator.calculate(input1); + } + + @Override + public void compute(final IterableInterval input1, + final RandomAccessibleInterval input2, + final IterableInterval output) + { + final Cursor in1Cursor = input1.localizingCursor(); + final RandomAccess in2Access = input2.randomAccess(); + final Cursor outCursor = output.cursor(); + while (in1Cursor.hasNext()) { + outCursor.next().set(in1Cursor.next()); + in2Access.setPosition(in1Cursor); + outCursor.get().${op.function}(in2Access.get()); + } + } + + @Override + public void mutate1(final IterableInterval arg, + final RandomAccessibleInterval in) + { + final Cursor in1Cursor = arg.localizingCursor(); + final RandomAccess in2Access = in.randomAccess(); + while (in1Cursor.hasNext()) { + in1Cursor.fwd(); + in2Access.setPosition(in1Cursor); + in1Cursor.get().${op.function}(in2Access.get()); + } + } + + @Override + public ${op.name} getIndependentInstance() { + return this; + } + } +#end +} diff --git a/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.list b/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.list index 5a5ad5fb48..e17e8cb431 100644 --- a/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.list +++ b/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.list @@ -1,11 +1,11 @@ -# Generated binary arithmetic ops with ImgLib2 NumericTypes. - -[NumericTypeBinaryMath.java] -ops = ``` -[ - [name: "Add", function: "add", verbs: "adds (+)"], - [name: "Divide", function: "div", verbs: "divides (/)"], - [name: "Subtract", function: "sub", verbs: "subtracts (-)"], - [name: "Multiply", function: "mul", verbs: "multiplies (*)"], -] -``` +# Generated binary arithmetic ops with ImgLib2 NumericTypes. + +[NumericTypeBinaryMath.java] +ops = ``` +[ + [name: "Add", function: "add", verbs: "adds (+)"], + [name: "Divide", function: "div", verbs: "divides (/)"], + [name: "Subtract", function: "sub", verbs: "subtracts (-)"], + [name: "Multiply", function: "mul", verbs: "multiplies (*)"], +] +``` diff --git a/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.vm b/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.vm index d7790df2a7..583b9b9fa0 100644 --- a/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.vm +++ b/src/main/templates/net/imagej/ops/math/NumericTypeBinaryMath.vm @@ -1,109 +1,109 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.Contingent; -import net.imagej.ops.Ops; -import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; -import net.imglib2.type.numeric.NumericType; - -import org.scijava.Priority; -import org.scijava.plugin.Plugin; - -/** - * Generated arithmetic ops with ImgLib2 {@link NumericType}s. - * - * @author Aparna Pal - * @author Leon Yang - * @author Curtis Rueden - */ -public final class NumericTypeBinaryMath { - - private NumericTypeBinaryMath() { - // NB: Prevent instantiation of utility class. - } - - @SuppressWarnings("rawtypes") - private static boolean compatible(NumericType in1, NumericType in2, - NumericType out) - { - if (out == null) { - return in1 == null || in2 == null || in1.getClass() == in2.getClass(); - } - return in1.getClass() == in2.getClass() && in1.getClass() == out.getClass(); - } -#foreach ($op in $ops) -#set ($iface = "Ops.Math.$op.name") - - /** Op that $op.verbs two NumericType values. */ - @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) - public static class $op.name> extends - AbstractBinaryHybridCFI implements $iface, Contingent - { - - @Override - public boolean conforms() { - return compatible(in1(), in2(), out()); - } - - @Override - public void compute(final T input1, final T input2, final T output) { - output.set(input1); - output.${op.function}(input2); - } - - @Override - public T createOutput(T input1, T input2) { - return input1.createVariable(); - } - - @Override - public void mutate1(final T arg, final T in) { - final T result = arg.createVariable(); - compute(arg, in, result); - arg.set(result); - } - - @Override - public void mutate2(final T in, final T arg) { - final T result = arg.createVariable(); - compute(in, arg, result); - arg.set(result); - } - - @Override - public ${op.name} getIndependentInstance() { - return this; - } - } -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.Contingent; +import net.imagej.ops.Ops; +import net.imagej.ops.special.hybrid.AbstractBinaryHybridCFI; +import net.imglib2.type.numeric.NumericType; + +import org.scijava.Priority; +import org.scijava.plugin.Plugin; + +/** + * Generated arithmetic ops with ImgLib2 {@link NumericType}s. + * + * @author Aparna Pal + * @author Leon Yang + * @author Curtis Rueden + */ +public final class NumericTypeBinaryMath { + + private NumericTypeBinaryMath() { + // NB: Prevent instantiation of utility class. + } + + @SuppressWarnings("rawtypes") + private static boolean compatible(NumericType in1, NumericType in2, + NumericType out) + { + if (out == null) { + return in1 == null || in2 == null || in1.getClass() == in2.getClass(); + } + return in1.getClass() == in2.getClass() && in1.getClass() == out.getClass(); + } +#foreach ($op in $ops) +#set ($iface = "Ops.Math.$op.name") + + /** Op that $op.verbs two NumericType values. */ + @Plugin(type = ${iface}.class, priority = Priority.HIGH_PRIORITY) + public static class $op.name> extends + AbstractBinaryHybridCFI implements $iface, Contingent + { + + @Override + public boolean conforms() { + return compatible(in1(), in2(), out()); + } + + @Override + public void compute(final T input1, final T input2, final T output) { + output.set(input1); + output.${op.function}(input2); + } + + @Override + public T createOutput(T input1, T input2) { + return input1.createVariable(); + } + + @Override + public void mutate1(final T arg, final T in) { + final T result = arg.createVariable(); + compute(arg, in, result); + arg.set(result); + } + + @Override + public void mutate2(final T in, final T arg) { + final T result = arg.createVariable(); + compute(in, arg, result); + arg.set(result); + } + + @Override + public ${op.name} getIndependentInstance() { + return this; + } + } +#end + +} diff --git a/src/main/templates/net/imagej/ops/math/PrimitiveMath.list b/src/main/templates/net/imagej/ops/math/PrimitiveMath.list index f0c1018ed3..823f4566f6 100644 --- a/src/main/templates/net/imagej/ops/math/PrimitiveMath.list +++ b/src/main/templates/net/imagej/ops/math/PrimitiveMath.list @@ -1,58 +1,58 @@ -# Generated unary and binary arithmetic ops with primitive types. -# -# Many of Java's binary numeric operators only work on ints and longs. -# And still more of them purport to work on bytes and shorts, but -# ultimately return int for the result. And most of Java's unary and -# binary Math functions only work on doubles. So rather than generate -# the entire cross-product of types-plus-operations, we do only those -# that are both valid and consistent regarding the return type. - -[PrimitiveMath.java] -types = ``` -[ - [name: "Integer", primitive: "int", code: "i", priority: 0.4], - [name: "Long", primitive: "long", code: "l", priority: 0.3], - [name: "Float", primitive: "float", code: "f", priority: 0.2], - [name: "Double", primitive: "double", code: "d", priority: 0.1] -] -``` -ops = ``` -[ - [name: "Add", operator: "+", unary: false, codes: "ilfd", verbs: "adds ({@literal +})"], - [name: "Subtract", operator: "-", unary: false, codes: "ilfd", verbs: "subtracts ({@literal -})"], - [name: "Multiply", operator: "*", unary: false, codes: "ilfd", verbs: "multiplies ({@literal *})"], - [name: "Divide", operator: "/", unary: false, codes: "ilfd", verbs: "divides ({@literal /})"], - [name: "Remainder", operator: "%", unary: false, codes: "ilfd", verbs: "computes the remainder ({@literal %}) of"], - [name: "And", operator: "&", unary: false, codes: "il", verbs: "computes the bitwise AND ({@literal &}) of"], - [name: "Or", operator: "|", unary: false, codes: "il", verbs: "computes the bitwise OR ({@literal |}) of"], - [name: "Xor", operator: "^", unary: false, codes: "il", verbs: "computes the bitwise XOR ({@literal ^}) of"], - [name: "LeftShift", operator: "<<", unary: false, codes: "il", verbs: "computes the signed left shift ({@literal <<}) of"], - [name: "RightShift", operator: ">>", unary: false, codes: "il", verbs: "computes the signed right shift ({@literal >>}) of"], - [name: "UnsignedRightShift", operator: ">>>", unary: false, codes: "il", verbs: "computes the unsigned right shift ({@literal >>>}) of"], - [name: "Max", function: "Math.max", unary: false, codes: "ilfd", verbs: "computes the maximum of"], - [name: "Min", function: "Math.min", unary: false, codes: "ilfd", verbs: "computes the minimum of"], - [name: "Power", function: "Math.pow", unary: false, codes: "d", verbs: "exponentiate"], - [name: "Complement", operator: "~", unary: true, codes: "il", verbs: "computes the bitwise complement ({@literal ~}) of"], - [name: "Negate", operator: "-", unary: true, codes: "ilfd", verbs: "negates ({@literal -})"], - [name: "Abs", function: "Math.abs", unary: true, codes: "ilfd", verbs: "computes the absolute value of"], - [name: "Arccos", function: "Math.acos", unary: true, codes: "d", verbs: "computes the arccosine of"], - [name: "Arcsin", function: "Math.asin", unary: true, codes: "d", verbs: "computes the arcsine of"], - [name: "Arctan", function: "Math.atan", unary: true, codes: "d", verbs: "computes the arctangent of"], - [name: "Ceil", function: "Math.ceil", unary: true, codes: "d", verbs: "computes the ceiling of"], - [name: "Cos", function: "Math.cos", unary: true, codes: "d", verbs: "computes the cosine of"], - [name: "Cosh", function: "Math.cosh", unary: true, codes: "d", verbs: "computes the hyperbolic cosine of"], - [name: "CubeRoot", function: "Math.cbrt", unary: true, codes: "d", verbs: "computes the cubic root of"], - [name: "Exp", function: "Math.exp", unary: true, codes: "d", verbs: "computes the natural exponent of"], - [name: "Floor", function: "Math.floor", unary: true, codes: "d", verbs: "computes the floor of"], - [name: "Log", function: "Math.log", unary: true, codes: "d", verbs: "computes the natural logarithm of"], - [name: "Log10", function: "Math.log10", unary: true, codes: "d", verbs: "computes the base 10 logarithm of"], - [name: "LogOnePlusX", function: "Math.log1p", unary: true, codes: "d", verbs: "computes the natural logarithm of one plus"], - [name: "Round", function: "Math.round", unary: true, codes: "fd", verbs: "rounds"], - [name: "Signum", function: "Math.signum", unary: true, codes: "fd", verbs: "computes the signum of"], - [name: "Sin", function: "Math.sin", unary: true, codes: "d", verbs: "computes the sine of"], - [name: "Sinh", function: "Math.sinh", unary: true, codes: "d", verbs: "computes the hyperbolic sine of"], - [name: "Sqrt", function: "Math.sqrt", unary: true, codes: "d", verbs: "computes the square root of"], - [name: "Tan", function: "Math.tan", unary: true, codes: "d", verbs: "computes the tangent of"], - [name: "Tanh", function: "Math.tanh", unary: true, codes: "d", verbs: "computes the hyperbolic tangent of"] -] -``` +# Generated unary and binary arithmetic ops with primitive types. +# +# Many of Java's binary numeric operators only work on ints and longs. +# And still more of them purport to work on bytes and shorts, but +# ultimately return int for the result. And most of Java's unary and +# binary Math functions only work on doubles. So rather than generate +# the entire cross-product of types-plus-operations, we do only those +# that are both valid and consistent regarding the return type. + +[PrimitiveMath.java] +types = ``` +[ + [name: "Integer", primitive: "int", code: "i", priority: 0.4], + [name: "Long", primitive: "long", code: "l", priority: 0.3], + [name: "Float", primitive: "float", code: "f", priority: 0.2], + [name: "Double", primitive: "double", code: "d", priority: 0.1] +] +``` +ops = ``` +[ + [name: "Add", operator: "+", unary: false, codes: "ilfd", verbs: "adds ({@literal +})"], + [name: "Subtract", operator: "-", unary: false, codes: "ilfd", verbs: "subtracts ({@literal -})"], + [name: "Multiply", operator: "*", unary: false, codes: "ilfd", verbs: "multiplies ({@literal *})"], + [name: "Divide", operator: "/", unary: false, codes: "ilfd", verbs: "divides ({@literal /})"], + [name: "Remainder", operator: "%", unary: false, codes: "ilfd", verbs: "computes the remainder ({@literal %}) of"], + [name: "And", operator: "&", unary: false, codes: "il", verbs: "computes the bitwise AND ({@literal &}) of"], + [name: "Or", operator: "|", unary: false, codes: "il", verbs: "computes the bitwise OR ({@literal |}) of"], + [name: "Xor", operator: "^", unary: false, codes: "il", verbs: "computes the bitwise XOR ({@literal ^}) of"], + [name: "LeftShift", operator: "<<", unary: false, codes: "il", verbs: "computes the signed left shift ({@literal <<}) of"], + [name: "RightShift", operator: ">>", unary: false, codes: "il", verbs: "computes the signed right shift ({@literal >>}) of"], + [name: "UnsignedRightShift", operator: ">>>", unary: false, codes: "il", verbs: "computes the unsigned right shift ({@literal >>>}) of"], + [name: "Max", function: "Math.max", unary: false, codes: "ilfd", verbs: "computes the maximum of"], + [name: "Min", function: "Math.min", unary: false, codes: "ilfd", verbs: "computes the minimum of"], + [name: "Power", function: "Math.pow", unary: false, codes: "d", verbs: "exponentiate"], + [name: "Complement", operator: "~", unary: true, codes: "il", verbs: "computes the bitwise complement ({@literal ~}) of"], + [name: "Negate", operator: "-", unary: true, codes: "ilfd", verbs: "negates ({@literal -})"], + [name: "Abs", function: "Math.abs", unary: true, codes: "ilfd", verbs: "computes the absolute value of"], + [name: "Arccos", function: "Math.acos", unary: true, codes: "d", verbs: "computes the arccosine of"], + [name: "Arcsin", function: "Math.asin", unary: true, codes: "d", verbs: "computes the arcsine of"], + [name: "Arctan", function: "Math.atan", unary: true, codes: "d", verbs: "computes the arctangent of"], + [name: "Ceil", function: "Math.ceil", unary: true, codes: "d", verbs: "computes the ceiling of"], + [name: "Cos", function: "Math.cos", unary: true, codes: "d", verbs: "computes the cosine of"], + [name: "Cosh", function: "Math.cosh", unary: true, codes: "d", verbs: "computes the hyperbolic cosine of"], + [name: "CubeRoot", function: "Math.cbrt", unary: true, codes: "d", verbs: "computes the cubic root of"], + [name: "Exp", function: "Math.exp", unary: true, codes: "d", verbs: "computes the natural exponent of"], + [name: "Floor", function: "Math.floor", unary: true, codes: "d", verbs: "computes the floor of"], + [name: "Log", function: "Math.log", unary: true, codes: "d", verbs: "computes the natural logarithm of"], + [name: "Log10", function: "Math.log10", unary: true, codes: "d", verbs: "computes the base 10 logarithm of"], + [name: "LogOnePlusX", function: "Math.log1p", unary: true, codes: "d", verbs: "computes the natural logarithm of one plus"], + [name: "Round", function: "Math.round", unary: true, codes: "fd", verbs: "rounds"], + [name: "Signum", function: "Math.signum", unary: true, codes: "fd", verbs: "computes the signum of"], + [name: "Sin", function: "Math.sin", unary: true, codes: "d", verbs: "computes the sine of"], + [name: "Sinh", function: "Math.sinh", unary: true, codes: "d", verbs: "computes the hyperbolic sine of"], + [name: "Sqrt", function: "Math.sqrt", unary: true, codes: "d", verbs: "computes the square root of"], + [name: "Tan", function: "Math.tan", unary: true, codes: "d", verbs: "computes the tangent of"], + [name: "Tanh", function: "Math.tanh", unary: true, codes: "d", verbs: "computes the hyperbolic tangent of"] +] +``` diff --git a/src/main/templates/net/imagej/ops/math/PrimitiveMath.vm b/src/main/templates/net/imagej/ops/math/PrimitiveMath.vm index a288a3f91d..b23ae59df6 100644 --- a/src/main/templates/net/imagej/ops/math/PrimitiveMath.vm +++ b/src/main/templates/net/imagej/ops/math/PrimitiveMath.vm @@ -1,88 +1,88 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import net.imagej.ops.AbstractOp; -import net.imagej.ops.Ops; - -import org.scijava.ItemIO; -import org.scijava.plugin.Parameter; -import org.scijava.plugin.Plugin; - -/** - * Generated arithmetic ops with primitive types. - * - * @author Curtis Rueden - */ -public final class PrimitiveMath { - - private PrimitiveMath() { - // NB: Prevent instantiation of utility class. - } -#foreach ($type in $types) -#foreach ($op in $ops) -#if ($op.codes.contains($type.code)) -#set ($iface = "Ops.Math.$op.name") - - /** Op that $op.verbs#if ($op.unary) a $type.primitive value#else two $type.primitive values#end. */ - @Plugin(type = ${iface}.class#if ($type.priority), priority = $type.priority#end) - public static class $type.name$op.name extends AbstractOp - implements $iface - { - @Parameter(type = ItemIO.OUTPUT) - private $type.primitive result; - - @Parameter - private $type.primitive a; -#if (!$op.unary) - - @Parameter - private $type.primitive b; -#end - - @Override - public void run() { -#if ($op.unary && $op.operator) - result = ${op.operator}a; -#elseif ($op.unary) - result = ${op.function}(a); -#elseif ($op.operator) - result = a $op.operator b; -#else - result = ${op.function}(a, b); -#end - } - } -#end -#end -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import net.imagej.ops.AbstractOp; +import net.imagej.ops.Ops; + +import org.scijava.ItemIO; +import org.scijava.plugin.Parameter; +import org.scijava.plugin.Plugin; + +/** + * Generated arithmetic ops with primitive types. + * + * @author Curtis Rueden + */ +public final class PrimitiveMath { + + private PrimitiveMath() { + // NB: Prevent instantiation of utility class. + } +#foreach ($type in $types) +#foreach ($op in $ops) +#if ($op.codes.contains($type.code)) +#set ($iface = "Ops.Math.$op.name") + + /** Op that $op.verbs#if ($op.unary) a $type.primitive value#else two $type.primitive values#end. */ + @Plugin(type = ${iface}.class#if ($type.priority), priority = $type.priority#end) + public static class $type.name$op.name extends AbstractOp + implements $iface + { + @Parameter(type = ItemIO.OUTPUT) + private $type.primitive result; + + @Parameter + private $type.primitive a; +#if (!$op.unary) + + @Parameter + private $type.primitive b; +#end + + @Override + public void run() { +#if ($op.unary && $op.operator) + result = ${op.operator}a; +#elseif ($op.unary) + result = ${op.function}(a); +#elseif ($op.operator) + result = a $op.operator b; +#else + result = ${op.function}(a, b); +#end + } + } +#end +#end +#end + +} diff --git a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.list b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.list index 6f1af6098f..36ace6bf42 100644 --- a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.list +++ b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.list @@ -1,23 +1,23 @@ -[ApplyThresholdMethod.java] -methods = ``` -[ - [name: "huang", iface: "Huang"], - [name: "ij1", iface: "IJ1"], - [name: "intermodes", iface: "Intermodes"], - [name: "isoData", iface: "IsoData"], - [name: "li", iface: "Li"], - [name: "maxEntropy", iface: "MaxEntropy"], - [name: "maxLikelihood", iface: "MaxLikelihood"], - [name: "mean", iface: "Mean"], - [name: "minError", iface: "MinError"], - [name: "minimum", iface: "Minimum"], - [name: "moments", iface: "Moments"], - [name: "otsu", iface: "Otsu"], - [name: "percentile", iface: "Percentile"], - [name: "renyiEntropy", iface: "RenyiEntropy"], - [name: "rosin", iface: "Rosin"], - [name: "shanbhag", iface: "Shanbhag"], - [name: "triangle", iface: "Triangle"], - [name: "yen", iface: "Yen"] -] -``` +[ApplyThresholdMethod.java] +methods = ``` +[ + [name: "huang", iface: "Huang"], + [name: "ij1", iface: "IJ1"], + [name: "intermodes", iface: "Intermodes"], + [name: "isoData", iface: "IsoData"], + [name: "li", iface: "Li"], + [name: "maxEntropy", iface: "MaxEntropy"], + [name: "maxLikelihood", iface: "MaxLikelihood"], + [name: "mean", iface: "Mean"], + [name: "minError", iface: "MinError"], + [name: "minimum", iface: "Minimum"], + [name: "moments", iface: "Moments"], + [name: "otsu", iface: "Otsu"], + [name: "percentile", iface: "Percentile"], + [name: "renyiEntropy", iface: "RenyiEntropy"], + [name: "rosin", iface: "Rosin"], + [name: "shanbhag", iface: "Shanbhag"], + [name: "triangle", iface: "Triangle"], + [name: "yen", iface: "Yen"] +] +``` diff --git a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.vm b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.vm index 9246057ece..fd6f34d95b 100644 --- a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.vm +++ b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethod.vm @@ -1,85 +1,85 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison and University of Konstanz. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.threshold; - -import net.imagej.ops.Ops; -import net.imagej.ops.special.computer.Computers; -import net.imagej.ops.special.computer.UnaryComputerOp; -import net.imglib2.histogram.Histogram1d; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.type.numeric.RealType; - -import org.scijava.plugin.Plugin; - -/** - * Ops which computes and apply a global threshold to an {@link Img}. - * - * @author Christian Dietz (University of Konstanz) - * @author Curtis Rueden - * @author Brian Northan - */ -public final class ApplyThresholdMethod { - - private ApplyThresholdMethod() { - // NB: Prevent instantiation of utility class. - } -#foreach ($method in $methods) -#set ($iface = "Ops.Threshold.${method.iface}") - - @Plugin(type = ${iface}.class) - public static class ${method.iface}> - extends AbstractApplyThresholdImg - implements ${iface} - { - - private UnaryComputerOp, T> thresholdComp; - - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - public void initialize() { - super.initialize(); - thresholdComp = (UnaryComputerOp) Computers.unary(ops(), - Ops.Threshold.${method.iface}.class, in().firstElement().getClass(), - Histogram1d.class); - } - - @Override - public T getThreshold(final IterableInterval input) { - final Histogram1d hist = histCreator.calculate(input); - final T type = input.firstElement().createVariable(); - thresholdComp.compute(hist, type); - return type; - } - } -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison and University of Konstanz. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.threshold; + +import net.imagej.ops.Ops; +import net.imagej.ops.special.computer.Computers; +import net.imagej.ops.special.computer.UnaryComputerOp; +import net.imglib2.histogram.Histogram1d; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.type.numeric.RealType; + +import org.scijava.plugin.Plugin; + +/** + * Ops which computes and apply a global threshold to an {@link Img}. + * + * @author Christian Dietz (University of Konstanz) + * @author Curtis Rueden + * @author Brian Northan + */ +public final class ApplyThresholdMethod { + + private ApplyThresholdMethod() { + // NB: Prevent instantiation of utility class. + } +#foreach ($method in $methods) +#set ($iface = "Ops.Threshold.${method.iface}") + + @Plugin(type = ${iface}.class) + public static class ${method.iface}> + extends AbstractApplyThresholdImg + implements ${iface} + { + + private UnaryComputerOp, T> thresholdComp; + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public void initialize() { + super.initialize(); + thresholdComp = (UnaryComputerOp) Computers.unary(ops(), + Ops.Threshold.${method.iface}.class, in().firstElement().getClass(), + Histogram1d.class); + } + + @Override + public T getThreshold(final IterableInterval input) { + final Histogram1d hist = histCreator.calculate(input); + final T type = input.firstElement().createVariable(); + thresholdComp.compute(hist, type); + return type; + } + } +#end + +} diff --git a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.list b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.list index 80c17caae8..9875896ed9 100644 --- a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.list +++ b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.list @@ -1,22 +1,22 @@ -[ApplyThresholdMethodLocal.java] -methods = ``` -[ - [name: "localHuang", iface: "Huang"], - [name: "localIj1", iface: "IJ1"], - [name: "localIntermodes", iface: "Intermodes"], - [name: "localIsoData", iface: "IsoData"], - [name: "localLi", iface: "Li"], - [name: "localMaxEntropy", iface: "MaxEntropy"], - [name: "localMaxLikelihood", iface: "MaxLikelihood"], - [name: "localMinError", iface: "MinError"], - [name: "localMinimum", iface: "Minimum"], - [name: "localMoments", iface: "Moments"], - [name: "localOtsu", iface: "Otsu"], - [name: "localPercentile", iface: "Percentile"], - [name: "localRenyiEntropy", iface: "RenyiEntropy"], - [name: "localRosin", iface: "Rosin"], - [name: "localShanbhag", iface: "Shanbhag"], - [name: "localTriangle", iface: "Triangle"], - [name: "localYen", iface: "Yen"] -] -``` +[ApplyThresholdMethodLocal.java] +methods = ``` +[ + [name: "localHuang", iface: "Huang"], + [name: "localIj1", iface: "IJ1"], + [name: "localIntermodes", iface: "Intermodes"], + [name: "localIsoData", iface: "IsoData"], + [name: "localLi", iface: "Li"], + [name: "localMaxEntropy", iface: "MaxEntropy"], + [name: "localMaxLikelihood", iface: "MaxLikelihood"], + [name: "localMinError", iface: "MinError"], + [name: "localMinimum", iface: "Minimum"], + [name: "localMoments", iface: "Moments"], + [name: "localOtsu", iface: "Otsu"], + [name: "localPercentile", iface: "Percentile"], + [name: "localRenyiEntropy", iface: "RenyiEntropy"], + [name: "localRosin", iface: "Rosin"], + [name: "localShanbhag", iface: "Shanbhag"], + [name: "localTriangle", iface: "Triangle"], + [name: "localYen", iface: "Yen"] +] +``` diff --git a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.vm b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.vm index d194b8570b..d604f5143c 100644 --- a/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.vm +++ b/src/main/templates/net/imagej/ops/threshold/ApplyThresholdMethodLocal.vm @@ -1,89 +1,89 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison and University of Konstanz. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.threshold; - -import net.imagej.ops.Ops; -import net.imagej.ops.map.neighborhood.CenterAwareComputerOp; -import net.imagej.ops.special.computer.Computers; -import net.imagej.ops.special.computer.UnaryComputerOp; -import net.imagej.ops.threshold.apply.LocalThreshold; -import net.imglib2.RandomAccessibleInterval; -import net.imglib2.histogram.Histogram1d; -import net.imglib2.type.logic.BitType; -import net.imglib2.type.numeric.RealType; - -import org.scijava.plugin.Plugin; - -/** - * Ops that apply a global threshold locally to a {@link RandomAccessibleInterval}. - * - * @author Stefan Helfrich (University of Konstanz) - */ -public final class ApplyThresholdMethodLocal { - - private ApplyThresholdMethodLocal() { - // NB: Prevent instantiation of utility class. - } -#foreach ($method in $methods) -#set ($iface = "Ops.Threshold.${method.iface}") - - @Plugin(type = ${iface}.class) - public static class Local${method.iface}Threshold> extends - LocalThreshold implements ${iface} - { - - @Override - protected CenterAwareComputerOp unaryComputer(final T inClass, - final BitType outClass) - { - final LocalThresholdMethodHistogram op = - new LocalThresholdMethodHistogram() - { - @SuppressWarnings({ "rawtypes", "unchecked" }) - @Override - protected UnaryComputerOp, T> - getThresholdComputer() - { - UnaryComputerOp unary = Computers.unary(ops(), - ${iface}.class, inClass.getClass(), Histogram1d.class); - return unary; - } - }; - - op.setEnvironment(ops()); - op.initialize(); - return op; - } - - } -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison and University of Konstanz. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.threshold; + +import net.imagej.ops.Ops; +import net.imagej.ops.map.neighborhood.CenterAwareComputerOp; +import net.imagej.ops.special.computer.Computers; +import net.imagej.ops.special.computer.UnaryComputerOp; +import net.imagej.ops.threshold.apply.LocalThreshold; +import net.imglib2.RandomAccessibleInterval; +import net.imglib2.histogram.Histogram1d; +import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.RealType; + +import org.scijava.plugin.Plugin; + +/** + * Ops that apply a global threshold locally to a {@link RandomAccessibleInterval}. + * + * @author Stefan Helfrich (University of Konstanz) + */ +public final class ApplyThresholdMethodLocal { + + private ApplyThresholdMethodLocal() { + // NB: Prevent instantiation of utility class. + } +#foreach ($method in $methods) +#set ($iface = "Ops.Threshold.${method.iface}") + + @Plugin(type = ${iface}.class) + public static class Local${method.iface}Threshold> extends + LocalThreshold implements ${iface} + { + + @Override + protected CenterAwareComputerOp unaryComputer(final T inClass, + final BitType outClass) + { + final LocalThresholdMethodHistogram op = + new LocalThresholdMethodHistogram() + { + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + protected UnaryComputerOp, T> + getThresholdComputer() + { + UnaryComputerOp unary = Computers.unary(ops(), + ${iface}.class, inClass.getClass(), Histogram1d.class); + return unary; + } + }; + + op.setEnvironment(ops()); + op.initialize(); + return op; + } + + } +#end + +} diff --git a/src/test/java/net/imagej/ops/create/CreateImgTest.java b/src/test/java/net/imagej/ops/create/CreateImgTest.java index 26d15e68aa..be76cf4199 100644 --- a/src/test/java/net/imagej/ops/create/CreateImgTest.java +++ b/src/test/java/net/imagej/ops/create/CreateImgTest.java @@ -35,21 +35,30 @@ import java.util.Random; import net.imagej.ops.AbstractOpTest; +import net.imagej.ops.create.img.CreateArrayImgFromArray; import net.imagej.ops.create.img.CreateImgFromDimsAndType; import net.imagej.ops.create.img.CreateImgFromImg; import net.imagej.ops.create.img.CreateImgFromInterval; +import net.imagej.ops.create.img.CreatePlanarImgFromArray; import net.imglib2.Dimensions; import net.imglib2.FinalDimensions; import net.imglib2.FinalInterval; +import net.imglib2.RandomAccess; import net.imglib2.img.Img; +import net.imglib2.img.ImgFactory; import net.imglib2.img.array.ArrayImgFactory; +import net.imglib2.img.basictypeaccess.array.DoubleArray; import net.imglib2.img.cell.CellImgFactory; +import net.imglib2.img.planar.PlanarImgFactory; import net.imglib2.img.planar.PlanarImgs; import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.ARGBType; import net.imglib2.type.numeric.integer.ByteType; import net.imglib2.type.numeric.integer.IntType; import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.Unsigned128BitType; import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedVariableBitLengthType; import net.imglib2.type.numeric.real.DoubleType; import net.imglib2.type.numeric.real.FloatType; import net.imglib2.util.Intervals; @@ -64,7 +73,11 @@ * @author Daniel Seebacher (University of Konstanz) * @author Tim-Oliver Buchholz (University of Konstanz) */ +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; +//@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class CreateImgTest extends AbstractOpTest { private static final int TEST_SIZE = 100; @@ -133,6 +146,137 @@ public void testImgFromImg() { assertEquals(img.firstElement().getClass(), newImg.firstElement() .getClass()); } + + // -- FromArray + + @Test + @SuppressWarnings("unchecked") + public void testImgFromArrayValue() { + final Random randomGenerator = new Random(); + + for (int i = 0; i < TEST_SIZE; i++) { + + // between 1 and 5 dimensions + final long[] dim = new long[randomGenerator.nextInt(4) + 2]; + + // source array length + int srcLen = 1; + + // between 2 and 10 pixels per dimensions + for (int j = 0; j < dim.length; j++) { + dim[j] = randomGenerator.nextInt(9) + 2; + srcLen *= dim[j]; + } + + double[] arr = new double[srcLen]; + + // arr = { 0, 0.1, 0.2, 0.3, ... } + for (int j = 0; j < srcLen; j++) + arr[j] = 0.1 * j; + + Img img = null; + + if ((i & 1) == 0) { + img = (Img) ops.run( + CreateArrayImgFromArray.Double.class, arr, dim); + } + else { + int sliceLen = (int) dim[0]; + if (dim.length >= 2) + sliceLen *= dim[1]; + double[][] arr2d = new double[srcLen / sliceLen][sliceLen]; + double n = 0; + for (int j = 0; j < arr2d.length; j++) + for (int k = 0; k < arr2d[0].length; k++) { + arr2d[j][k] = n; + n += 0.1; + } + img = (Img) ops.run( + CreatePlanarImgFromArray.Double.class, arr2d, dim); + } + + RandomAccess ra = img.randomAccess(); + + // check random pixels + int[] coord = new int[dim.length]; + for (int j = 0; j < 10; j++) { + int inputIndex = 0; + int sliceSize = 1; + for (int k = 0; k < dim.length; k++) { + coord[k] = randomGenerator.nextInt((int) dim[k]); + inputIndex += coord[k] * sliceSize; + sliceSize *= dim[k]; + } + ra.setPosition(coord); + assertEquals("Pixel value: ", ra.get().getRealDouble(), arr[inputIndex], 0.05); + } + } + } + + @Test + public void testImgFromArrayFactoryAndVarLenConforms() { + final Random rng = new Random(); + final Dimensions dim = new FinalDimensions(1, 1, 1); + final long[] in = {Long.MIN_VALUE}; + + for (int i = 0; i < TEST_SIZE; i++) { + @SuppressWarnings("unchecked") + final Img arrayImg = + (Img) ops.run( + CreateArrayImgFromArray.UintVarLen.class, in, dim, rng.nextInt(63) + 1); + final Class arrayFactoryClass = arrayImg.factory().getClass(); + assertEquals("Image Factory: ", ArrayImgFactory.class, arrayFactoryClass); + + @SuppressWarnings("unchecked") + final Img planarImg = + (Img) ops.run( + CreatePlanarImgFromArray.UintVarLen.class, new long[][] {in}, dim, rng.nextInt(63) + 1); + final Class planarFactoryClass = planarImg.factory().getClass(); + assertEquals("Image Factory: ", PlanarImgFactory.class, planarFactoryClass); + } + + final long[] in1 = new long[] {Long.MIN_VALUE, Long.MIN_VALUE}; + + @SuppressWarnings("unchecked") + final Img arrayImg = + (Img) ops.run(CreateArrayImgFromArray.Uint128.class, in1, dim); + final Class arrayFactoryClass = arrayImg.factory().getClass(); + assertEquals("Image Factory: ", ArrayImgFactory.class, arrayFactoryClass); + + @SuppressWarnings("unchecked") + final Img planarImg = + (Img) ops.run( + CreatePlanarImgFromArray.Uint128.class, new long[][] {in1}, dim); + final Class planarFactoryClass = planarImg.factory().getClass(); + assertEquals("Image Factory: ", PlanarImgFactory.class, planarFactoryClass); + } + + @Test + public void testImgFromArrayType() { + final Dimensions dim = new FinalDimensions(1, 1, 1); + final long[] in = {1}; + + @SuppressWarnings("unchecked") + final Img uvblImg = + (Img) ops.run( + CreateArrayImgFromArray.UintVarLen.class, in, dim, 5); + final Class uvblImgClass = uvblImg.firstElement().getClass(); + assertEquals("Image Type: ", UnsignedVariableBitLengthType.class, uvblImgClass); + + @SuppressWarnings("unchecked") + final Img argbImg = + (Img) ops.run( + CreateArrayImgFromArray.ARGB32.class, in, dim); + final Class argbImgClass = argbImg.firstElement().getClass(); + assertEquals("Image Type: ", ARGBType.class, argbImgClass); + + @SuppressWarnings("unchecked") + final Img bitImg = + (Img) ops.run( + CreateArrayImgFromArray.Bit.class, new long[] {1L}, dim); + final Class bitImgClass = bitImg.firstElement().getClass(); + assertEquals("Image Type: ", BitType.class, bitImgClass); + } @Test public void testImageFactory() { diff --git a/src/test/resources/net/imagej/ops/features/2d_geometric_features_polygon.txt b/src/test/resources/net/imagej/ops/features/2d_geometric_features_polygon.txt index 0e760b2508..e0a306f20e 100644 --- a/src/test/resources/net/imagej/ops/features/2d_geometric_features_polygon.txt +++ b/src/test/resources/net/imagej/ops/features/2d_geometric_features_polygon.txt @@ -1,305 +1,305 @@ -26.0 6.0 -27.0 6.0 -28.0 6.0 -29.0 6.0 -30.0 6.0 -31.0 6.0 -31.0 7.0 -31.0 8.0 -31.0 9.0 -31.0 10.0 -31.0 11.0 -31.0 12.0 -31.0 13.0 -32.0 14.0 -33.0 14.0 -34.0 13.0 -35.0 13.0 -36.0 12.0 -37.0 12.0 -38.0 11.0 -39.0 11.0 -40.0 10.0 -41.0 10.0 -42.0 9.0 -42.0 10.0 -43.0 11.0 -43.0 12.0 -44.0 13.0 -44.0 14.0 -45.0 15.0 -45.0 16.0 -46.0 17.0 -46.0 18.0 -47.0 19.0 -47.0 20.0 -48.0 21.0 -49.0 22.0 -49.0 23.0 -50.0 24.0 -50.0 25.0 -51.0 26.0 -51.0 27.0 -50.0 27.0 -49.0 28.0 -48.0 29.0 -47.0 30.0 -47.0 31.0 -46.0 32.0 -46.0 33.0 -45.0 34.0 -45.0 35.0 -44.0 36.0 -44.0 37.0 -44.0 38.0 -44.0 39.0 -44.0 40.0 -44.0 41.0 -44.0 42.0 -44.0 43.0 -44.0 44.0 -45.0 45.0 -45.0 46.0 -46.0 47.0 -46.0 48.0 -47.0 49.0 -47.0 50.0 -48.0 51.0 -49.0 52.0 -50.0 53.0 -51.0 53.0 -52.0 54.0 -53.0 54.0 -54.0 55.0 -55.0 55.0 -56.0 56.0 -57.0 56.0 -58.0 56.0 -59.0 56.0 -60.0 56.0 -61.0 56.0 -62.0 56.0 -63.0 56.0 -64.0 56.0 -65.0 55.0 -66.0 55.0 -67.0 56.0 -67.0 57.0 -68.0 58.0 -68.0 59.0 -69.0 60.0 -69.0 61.0 -70.0 62.0 -70.0 63.0 -71.0 64.0 -72.0 65.0 -72.0 66.0 -73.0 67.0 -73.0 68.0 -74.0 69.0 -74.0 70.0 -75.0 71.0 -75.0 72.0 -76.0 73.0 -76.0 74.0 -77.0 75.0 -77.0 76.0 -78.0 77.0 -77.0 77.0 -76.0 78.0 -75.0 78.0 -74.0 79.0 -73.0 79.0 -72.0 80.0 -71.0 80.0 -70.0 81.0 -69.0 81.0 -68.0 82.0 -67.0 82.0 -66.0 83.0 -65.0 83.0 -64.0 84.0 -63.0 84.0 -62.0 85.0 -61.0 85.0 -60.0 86.0 -59.0 86.0 -58.0 87.0 -57.0 88.0 -56.0 88.0 -55.0 89.0 -54.0 89.0 -53.0 90.0 -53.0 91.0 -53.0 92.0 -53.0 93.0 -53.0 94.0 -53.0 95.0 -53.0 96.0 -53.0 97.0 -53.0 98.0 -52.0 99.0 -52.0 100.0 -51.0 101.0 -51.0 102.0 -50.0 103.0 -50.0 104.0 -49.0 105.0 -48.0 106.0 -47.0 106.0 -46.0 107.0 -45.0 107.0 -44.0 108.0 -43.0 108.0 -42.0 109.0 -41.0 109.0 -40.0 109.0 -39.0 109.0 -38.0 109.0 -37.0 109.0 -36.0 109.0 -35.0 109.0 -34.0 109.0 -33.0 108.0 -32.0 108.0 -31.0 107.0 -30.0 107.0 -29.0 106.0 -28.0 106.0 -27.0 105.0 -26.0 104.0 -26.0 103.0 -25.0 102.0 -25.0 101.0 -24.0 100.0 -24.0 99.0 -23.0 98.0 -23.0 97.0 -23.0 96.0 -23.0 95.0 -23.0 94.0 -23.0 93.0 -23.0 92.0 -23.0 91.0 -23.0 90.0 -24.0 89.0 -24.0 88.0 -25.0 87.0 -25.0 86.0 -26.0 85.0 -26.0 84.0 -27.0 83.0 -28.0 82.0 -28.0 81.0 -28.0 80.0 -27.0 79.0 -27.0 78.0 -26.0 77.0 -26.0 76.0 -25.0 75.0 -25.0 74.0 -24.0 73.0 -24.0 72.0 -23.0 71.0 -22.0 70.0 -22.0 69.0 -21.0 68.0 -21.0 67.0 -20.0 66.0 -20.0 65.0 -19.0 64.0 -19.0 63.0 -20.0 63.0 -21.0 63.0 -22.0 63.0 -23.0 63.0 -24.0 63.0 -25.0 63.0 -26.0 63.0 -27.0 63.0 -28.0 63.0 -29.0 63.0 -30.0 62.0 -30.0 61.0 -30.0 60.0 -30.0 59.0 -30.0 58.0 -30.0 57.0 -30.0 56.0 -30.0 55.0 -30.0 54.0 -29.0 53.0 -28.0 53.0 -27.0 53.0 -26.0 53.0 -25.0 53.0 -24.0 53.0 -23.0 53.0 -22.0 53.0 -21.0 53.0 -20.0 53.0 -19.0 53.0 -18.0 53.0 -17.0 53.0 -16.0 53.0 -15.0 53.0 -14.0 53.0 -13.0 53.0 -13.0 52.0 -12.0 51.0 -12.0 50.0 -11.0 49.0 -11.0 48.0 -10.0 47.0 -10.0 46.0 -9.0 45.0 -9.0 44.0 -8.0 43.0 -7.0 42.0 -7.0 41.0 -6.0 40.0 -6.0 39.0 -5.0 38.0 -5.0 37.0 -4.0 36.0 -4.0 35.0 -3.0 34.0 -3.0 33.0 -2.0 32.0 -2.0 31.0 -1.0 30.0 -2.0 29.0 -3.0 29.0 -4.0 28.0 -5.0 28.0 -6.0 27.0 -7.0 27.0 -8.0 26.0 -9.0 26.0 -10.0 25.0 -11.0 25.0 -12.0 24.0 -13.0 24.0 -14.0 23.0 -15.0 23.0 -16.0 22.0 -17.0 22.0 -18.0 21.0 -19.0 21.0 -20.0 20.0 -21.0 20.0 -22.0 19.0 -23.0 19.0 -24.0 18.0 -25.0 18.0 -26.0 17.0 -26.0 16.0 -26.0 15.0 -26.0 14.0 -26.0 13.0 -26.0 12.0 -26.0 11.0 -26.0 10.0 -26.0 9.0 -26.0 8.0 -26.0 7.0 +26.0 6.0 +27.0 6.0 +28.0 6.0 +29.0 6.0 +30.0 6.0 +31.0 6.0 +31.0 7.0 +31.0 8.0 +31.0 9.0 +31.0 10.0 +31.0 11.0 +31.0 12.0 +31.0 13.0 +32.0 14.0 +33.0 14.0 +34.0 13.0 +35.0 13.0 +36.0 12.0 +37.0 12.0 +38.0 11.0 +39.0 11.0 +40.0 10.0 +41.0 10.0 +42.0 9.0 +42.0 10.0 +43.0 11.0 +43.0 12.0 +44.0 13.0 +44.0 14.0 +45.0 15.0 +45.0 16.0 +46.0 17.0 +46.0 18.0 +47.0 19.0 +47.0 20.0 +48.0 21.0 +49.0 22.0 +49.0 23.0 +50.0 24.0 +50.0 25.0 +51.0 26.0 +51.0 27.0 +50.0 27.0 +49.0 28.0 +48.0 29.0 +47.0 30.0 +47.0 31.0 +46.0 32.0 +46.0 33.0 +45.0 34.0 +45.0 35.0 +44.0 36.0 +44.0 37.0 +44.0 38.0 +44.0 39.0 +44.0 40.0 +44.0 41.0 +44.0 42.0 +44.0 43.0 +44.0 44.0 +45.0 45.0 +45.0 46.0 +46.0 47.0 +46.0 48.0 +47.0 49.0 +47.0 50.0 +48.0 51.0 +49.0 52.0 +50.0 53.0 +51.0 53.0 +52.0 54.0 +53.0 54.0 +54.0 55.0 +55.0 55.0 +56.0 56.0 +57.0 56.0 +58.0 56.0 +59.0 56.0 +60.0 56.0 +61.0 56.0 +62.0 56.0 +63.0 56.0 +64.0 56.0 +65.0 55.0 +66.0 55.0 +67.0 56.0 +67.0 57.0 +68.0 58.0 +68.0 59.0 +69.0 60.0 +69.0 61.0 +70.0 62.0 +70.0 63.0 +71.0 64.0 +72.0 65.0 +72.0 66.0 +73.0 67.0 +73.0 68.0 +74.0 69.0 +74.0 70.0 +75.0 71.0 +75.0 72.0 +76.0 73.0 +76.0 74.0 +77.0 75.0 +77.0 76.0 +78.0 77.0 +77.0 77.0 +76.0 78.0 +75.0 78.0 +74.0 79.0 +73.0 79.0 +72.0 80.0 +71.0 80.0 +70.0 81.0 +69.0 81.0 +68.0 82.0 +67.0 82.0 +66.0 83.0 +65.0 83.0 +64.0 84.0 +63.0 84.0 +62.0 85.0 +61.0 85.0 +60.0 86.0 +59.0 86.0 +58.0 87.0 +57.0 88.0 +56.0 88.0 +55.0 89.0 +54.0 89.0 +53.0 90.0 +53.0 91.0 +53.0 92.0 +53.0 93.0 +53.0 94.0 +53.0 95.0 +53.0 96.0 +53.0 97.0 +53.0 98.0 +52.0 99.0 +52.0 100.0 +51.0 101.0 +51.0 102.0 +50.0 103.0 +50.0 104.0 +49.0 105.0 +48.0 106.0 +47.0 106.0 +46.0 107.0 +45.0 107.0 +44.0 108.0 +43.0 108.0 +42.0 109.0 +41.0 109.0 +40.0 109.0 +39.0 109.0 +38.0 109.0 +37.0 109.0 +36.0 109.0 +35.0 109.0 +34.0 109.0 +33.0 108.0 +32.0 108.0 +31.0 107.0 +30.0 107.0 +29.0 106.0 +28.0 106.0 +27.0 105.0 +26.0 104.0 +26.0 103.0 +25.0 102.0 +25.0 101.0 +24.0 100.0 +24.0 99.0 +23.0 98.0 +23.0 97.0 +23.0 96.0 +23.0 95.0 +23.0 94.0 +23.0 93.0 +23.0 92.0 +23.0 91.0 +23.0 90.0 +24.0 89.0 +24.0 88.0 +25.0 87.0 +25.0 86.0 +26.0 85.0 +26.0 84.0 +27.0 83.0 +28.0 82.0 +28.0 81.0 +28.0 80.0 +27.0 79.0 +27.0 78.0 +26.0 77.0 +26.0 76.0 +25.0 75.0 +25.0 74.0 +24.0 73.0 +24.0 72.0 +23.0 71.0 +22.0 70.0 +22.0 69.0 +21.0 68.0 +21.0 67.0 +20.0 66.0 +20.0 65.0 +19.0 64.0 +19.0 63.0 +20.0 63.0 +21.0 63.0 +22.0 63.0 +23.0 63.0 +24.0 63.0 +25.0 63.0 +26.0 63.0 +27.0 63.0 +28.0 63.0 +29.0 63.0 +30.0 62.0 +30.0 61.0 +30.0 60.0 +30.0 59.0 +30.0 58.0 +30.0 57.0 +30.0 56.0 +30.0 55.0 +30.0 54.0 +29.0 53.0 +28.0 53.0 +27.0 53.0 +26.0 53.0 +25.0 53.0 +24.0 53.0 +23.0 53.0 +22.0 53.0 +21.0 53.0 +20.0 53.0 +19.0 53.0 +18.0 53.0 +17.0 53.0 +16.0 53.0 +15.0 53.0 +14.0 53.0 +13.0 53.0 +13.0 52.0 +12.0 51.0 +12.0 50.0 +11.0 49.0 +11.0 48.0 +10.0 47.0 +10.0 46.0 +9.0 45.0 +9.0 44.0 +8.0 43.0 +7.0 42.0 +7.0 41.0 +6.0 40.0 +6.0 39.0 +5.0 38.0 +5.0 37.0 +4.0 36.0 +4.0 35.0 +3.0 34.0 +3.0 33.0 +2.0 32.0 +2.0 31.0 +1.0 30.0 +2.0 29.0 +3.0 29.0 +4.0 28.0 +5.0 28.0 +6.0 27.0 +7.0 27.0 +8.0 26.0 +9.0 26.0 +10.0 25.0 +11.0 25.0 +12.0 24.0 +13.0 24.0 +14.0 23.0 +15.0 23.0 +16.0 22.0 +17.0 22.0 +18.0 21.0 +19.0 21.0 +20.0 20.0 +21.0 20.0 +22.0 19.0 +23.0 19.0 +24.0 18.0 +25.0 18.0 +26.0 17.0 +26.0 16.0 +26.0 15.0 +26.0 14.0 +26.0 13.0 +26.0 12.0 +26.0 11.0 +26.0 10.0 +26.0 9.0 +26.0 8.0 +26.0 7.0 diff --git a/src/test/resources/net/imagej/ops/features/3d_geometric_features_mesh.txt b/src/test/resources/net/imagej/ops/features/3d_geometric_features_mesh.txt index 1e7dd3876b..284f09a22c 100644 --- a/src/test/resources/net/imagej/ops/features/3d_geometric_features_mesh.txt +++ b/src/test/resources/net/imagej/ops/features/3d_geometric_features_mesh.txt @@ -1,1092 +1,1092 @@ -6.0 6.0 1.0 -5.0 6.0 1.0 -6.0 5.0 1.0 -6.0 5.0 1.0 -7.0 5.0 1.0 -6.0 6.0 1.0 -6.0 4.0 2.0 -5.0 4.0 2.0 -6.0 3.0 2.0 -7.0 4.0 2.0 -6.0 3.0 2.0 -7.0 3.0 2.0 -7.0 4.0 2.0 -6.0 4.0 2.0 -6.0 3.0 2.0 -7.0 4.0 2.0 -7.0 3.0 2.0 -8.0 4.0 2.0 -5.0 5.0 2.0 -4.0 5.0 2.0 -5.0 4.0 2.0 -5.0 5.0 2.0 -6.0 4.0 2.0 -6.0 5.0 1.0 -5.0 5.0 2.0 -5.0 4.0 2.0 -6.0 4.0 2.0 -7.0 4.0 2.0 -7.0 5.0 1.0 -6.0 4.0 2.0 -6.0 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.0 6.0 8.0 +4.0 6.0 8.0 +3.0 5.0 8.0 +4.0 5.0 8.0 +5.0 6.0 8.0 +5.0 5.0 8.0 +4.0 6.0 8.0 +5.0 6.0 8.0 +4.0 5.0 8.0 +5.0 5.0 8.0 +5.0 6.0 8.0 +6.0 5.0 8.0 +7.0 5.0 8.0 +6.0 5.0 8.0 +7.0 6.0 8.0 +7.0 5.0 8.0 +8.0 6.0 8.0 +8.0 5.0 8.0 +7.0 6.0 8.0 +8.0 6.0 8.0 +7.0 5.0 8.0 +4.0 6.0 8.0 +3.0 6.0 8.0 +4.0 7.0 8.0 +4.0 6.0 8.0 +4.0 7.0 8.0 +5.0 6.0 8.0 diff --git a/src/test/templates/Test.list b/src/test/templates/Test.list index ebd4182218..826d0d62a9 100644 --- a/src/test/templates/Test.list +++ b/src/test/templates/Test.list @@ -1,10 +1,10 @@ -[TestTemplate.txt] -name = "Pinky" -multiLine = ``` -'''\ -Ten weary, footsore travelers, -all in a woeful plight, -sought shelter in a way-side inn -one dark and rainy night''' -``` -mapList = [[name:"alice", age:123], [ name : "bob", age:1.2], [name : "charly"]] +[TestTemplate.txt] +name = "Pinky" +multiLine = ``` +'''\ +Ten weary, footsore travelers, +all in a woeful plight, +sought shelter in a way-side inn +one dark and rainy night''' +``` +mapList = [[name:"alice", age:123], [ name : "bob", age:1.2], [name : "charly"]] diff --git a/src/test/templates/Test.vm b/src/test/templates/Test.vm index a692149d7e..5902f291db 100644 --- a/src/test/templates/Test.vm +++ b/src/test/templates/Test.vm @@ -1,8 +1,8 @@ -Template test: $name -Multi-line: $multiLine...! - -The list of maps: -#foreach( $entry in $mapList ) -${entry.name} #if( ${entry.age} )who is ${entry.age} years old#end - -#end +Template test: $name +Multi-line: $multiLine...! + +The list of maps: +#foreach( $entry in $mapList ) +${entry.name} #if( ${entry.age} )who is ${entry.age} years old#end + +#end diff --git a/src/test/templates/TestTypes.list b/src/test/templates/TestTypes.list index 24c3639ce0..025f5e7839 100644 --- a/src/test/templates/TestTypes.list +++ b/src/test/templates/TestTypes.list @@ -1,45 +1,45 @@ -[TestTypes.txt] - -# pattern matches for each supported type -bool1 = true -bool2 = false -double1 = 3.4 -double2 = 0.1e234 -float1 = 4.3e21f -float2 = 765f -int1 = 12345 -int2 = -98765 -long1 = 0L -long2 = 987654321123456789L -string01 = "John Q. Public" -string02 = "Dwayne \"The Rock\" Johnson" -string03 = "\"\"\"\\\"\\\\\"\\\\\\\\\\\"" -sbool1 = "true" -sbool2 = "false" -sdouble1 = "3.4" -sdouble2 = "0.1e234" -sfloat1 = "4.3e21f" -sfloat2 = "765f" -sint1 = "12345" -sint2 = "-98765" -slong1 = "0L" -slong2 = "987654321123456789L" -slist = "['not', 'a', 'list']" -smap = "[just: 'a', simple: 'string']" - -# list element type can vary -list = [false, true, 1.0, 2f, 3, 5L, "8", "[thirt: 'een']", "[21, 34]"] - -# map value type can vary -map = ``` -[ - s1: 'Hello, world!', - s2: 'x23', - yes: true, - no: false, - pi: 3.149, - e: 2.71828182846f, - notList: "['also', 'not', 'a', 'list']", - notMap: "[also: 'only', a: 'string']" -] -``` +[TestTypes.txt] + +# pattern matches for each supported type +bool1 = true +bool2 = false +double1 = 3.4 +double2 = 0.1e234 +float1 = 4.3e21f +float2 = 765f +int1 = 12345 +int2 = -98765 +long1 = 0L +long2 = 987654321123456789L +string01 = "John Q. Public" +string02 = "Dwayne \"The Rock\" Johnson" +string03 = "\"\"\"\\\"\\\\\"\\\\\\\\\\\"" +sbool1 = "true" +sbool2 = "false" +sdouble1 = "3.4" +sdouble2 = "0.1e234" +sfloat1 = "4.3e21f" +sfloat2 = "765f" +sint1 = "12345" +sint2 = "-98765" +slong1 = "0L" +slong2 = "987654321123456789L" +slist = "['not', 'a', 'list']" +smap = "[just: 'a', simple: 'string']" + +# list element type can vary +list = [false, true, 1.0, 2f, 3, 5L, "8", "[thirt: 'een']", "[21, 34]"] + +# map value type can vary +map = ``` +[ + s1: 'Hello, world!', + s2: 'x23', + yes: true, + no: false, + pi: 3.149, + e: 2.71828182846f, + notList: "['also', 'not', 'a', 'list']", + notMap: "[also: 'only', a: 'string']" +] +``` diff --git a/src/test/templates/TestTypes.vm b/src/test/templates/TestTypes.vm index a54040f89f..6b3889e9da 100644 --- a/src/test/templates/TestTypes.vm +++ b/src/test/templates/TestTypes.vm @@ -1,80 +1,80 @@ -java.lang.Boolean $bool1.getClass().getName() -true $bool1 -java.lang.Boolean $bool2.getClass().getName() -false $bool2 -java.math.BigDecimal $double1.getClass().getName() -3.4 $double1 -java.math.BigDecimal $double2.getClass().getName() -1E+233 $double2 -java.lang.Float $float1.getClass().getName() -4.3E21 $float1 -java.lang.Float $float2.getClass().getName() -765.0 $float2 -java.lang.Integer $int1.getClass().getName() -12345 $int1 -java.lang.Integer $int2.getClass().getName() --98765 $int2 -java.lang.Long $long1.getClass().getName() -0 $long1 -java.lang.Long $long2.getClass().getName() -987654321123456789 $long2 -java.lang.String $string01.getClass().getName() -John Q. Public $string01 -java.lang.String $string02.getClass().getName() -Dwayne "The Rock" Johnson $string02 -java.lang.String $string03.getClass().getName() -"""\"\\"\\\\\" $string03 -java.lang.String $sbool1.getClass().getName() -true $sbool1 -java.lang.String $sbool2.getClass().getName() -false $sbool2 -java.lang.String $sdouble1.getClass().getName() -3.4 $sdouble1 -java.lang.String $sdouble2.getClass().getName() -0.1e234 $sdouble2 -java.lang.String $sfloat1.getClass().getName() -4.3e21f $sfloat1 -java.lang.String $sfloat2.getClass().getName() -765f $sfloat2 -java.lang.String $sint1.getClass().getName() -12345 $sint1 -java.lang.String $sint2.getClass().getName() --98765 $sint2 -java.lang.String $slong1.getClass().getName() -0L $slong1 -java.lang.String $slong2.getClass().getName() -987654321123456789L $slong2 -false $list[0] -java.lang.Boolean $list[0].getClass().getName() -true $list[1] -java.lang.Boolean $list[1].getClass().getName() -1.0 $list[2] -java.math.BigDecimal $list[2].getClass().getName() -2.0 $list[3] -java.lang.Float $list[3].getClass().getName() -3 $list[4] -java.lang.Integer $list[4].getClass().getName() -5 $list[5] -java.lang.Long $list[5].getClass().getName() -8 $list[6] -java.lang.String $list[6].getClass().getName() -[thirt: 'een'] $list[7] -java.lang.String $list[7].getClass().getName() -[21, 34] $list[8] -java.lang.String $list[8].getClass().getName() -Hello, world! $map.s1 -java.lang.String $map.s1.getClass().getName() -x23 $map.s2 -java.lang.String $map.s2.getClass().getName() -true $map.yes -java.lang.Boolean $map.yes.getClass().getName() -false $map.no -java.lang.Boolean $map.no.getClass().getName() -3.149 $map.pi -java.math.BigDecimal $map.pi.getClass().getName() -2.7182817 $map.e -java.lang.Float $map.e.getClass().getName() -['also', 'not', 'a', 'list'] $map.notList -java.lang.String $map.notList.getClass().getName() -[also: 'only', a: 'string'] $map.notMap -java.lang.String $map.notMap.getClass().getName() +java.lang.Boolean $bool1.getClass().getName() +true $bool1 +java.lang.Boolean $bool2.getClass().getName() +false $bool2 +java.math.BigDecimal $double1.getClass().getName() +3.4 $double1 +java.math.BigDecimal $double2.getClass().getName() +1E+233 $double2 +java.lang.Float $float1.getClass().getName() +4.3E21 $float1 +java.lang.Float $float2.getClass().getName() +765.0 $float2 +java.lang.Integer $int1.getClass().getName() +12345 $int1 +java.lang.Integer $int2.getClass().getName() +-98765 $int2 +java.lang.Long $long1.getClass().getName() +0 $long1 +java.lang.Long $long2.getClass().getName() +987654321123456789 $long2 +java.lang.String $string01.getClass().getName() +John Q. Public $string01 +java.lang.String $string02.getClass().getName() +Dwayne "The Rock" Johnson $string02 +java.lang.String $string03.getClass().getName() +"""\"\\"\\\\\" $string03 +java.lang.String $sbool1.getClass().getName() +true $sbool1 +java.lang.String $sbool2.getClass().getName() +false $sbool2 +java.lang.String $sdouble1.getClass().getName() +3.4 $sdouble1 +java.lang.String $sdouble2.getClass().getName() +0.1e234 $sdouble2 +java.lang.String $sfloat1.getClass().getName() +4.3e21f $sfloat1 +java.lang.String $sfloat2.getClass().getName() +765f $sfloat2 +java.lang.String $sint1.getClass().getName() +12345 $sint1 +java.lang.String $sint2.getClass().getName() +-98765 $sint2 +java.lang.String $slong1.getClass().getName() +0L $slong1 +java.lang.String $slong2.getClass().getName() +987654321123456789L $slong2 +false $list[0] +java.lang.Boolean $list[0].getClass().getName() +true $list[1] +java.lang.Boolean $list[1].getClass().getName() +1.0 $list[2] +java.math.BigDecimal $list[2].getClass().getName() +2.0 $list[3] +java.lang.Float $list[3].getClass().getName() +3 $list[4] +java.lang.Integer $list[4].getClass().getName() +5 $list[5] +java.lang.Long $list[5].getClass().getName() +8 $list[6] +java.lang.String $list[6].getClass().getName() +[thirt: 'een'] $list[7] +java.lang.String $list[7].getClass().getName() +[21, 34] $list[8] +java.lang.String $list[8].getClass().getName() +Hello, world! $map.s1 +java.lang.String $map.s1.getClass().getName() +x23 $map.s2 +java.lang.String $map.s2.getClass().getName() +true $map.yes +java.lang.Boolean $map.yes.getClass().getName() +false $map.no +java.lang.Boolean $map.no.getClass().getName() +3.149 $map.pi +java.math.BigDecimal $map.pi.getClass().getName() +2.7182817 $map.e +java.lang.Float $map.e.getClass().getName() +['also', 'not', 'a', 'list'] $map.notList +java.lang.String $map.notList.getClass().getName() +[also: 'only', a: 'string'] $map.notMap +java.lang.String $map.notMap.getClass().getName() diff --git a/src/test/templates/net/imagej/ops/convert/ConvertImagesTest.list b/src/test/templates/net/imagej/ops/convert/ConvertImagesTest.list index dae9675d6c..a627f8e8ba 100644 --- a/src/test/templates/net/imagej/ops/convert/ConvertImagesTest.list +++ b/src/test/templates/net/imagej/ops/convert/ConvertImagesTest.list @@ -1,24 +1,24 @@ -[ConvertImagesTest.java] -ops = ``` -[ -// NB: Some tests disabled until ImgLib2 is updated in -// accordance with https://github.com/imglib/imglib2#111 - [name: "Bit", type: "net.imglib2.type.logic.BitType"], -// [name: "Uint2", type: "net.imglib2.type.numeric.integer.Unsigned2BitType"], -// [name: "Uint4", type: "net.imglib2.type.numeric.integer.Unsigned4BitType"], - [name: "Int8", type: "net.imglib2.type.numeric.integer.ByteType"], - [name: "Uint8", type: "net.imglib2.type.numeric.integer.UnsignedByteType"], -// [name: "Uint12", type: "net.imglib2.type.numeric.integer.Unsigned12BitType"], - [name: "Int16", type: "net.imglib2.type.numeric.integer.ShortType"], - [name: "Uint16", type: "net.imglib2.type.numeric.integer.UnsignedShortType"], - [name: "Int32", type: "net.imglib2.type.numeric.integer.IntType"], - [name: "Uint32", type: "net.imglib2.type.numeric.integer.UnsignedIntType"], - [name: "Int64", type: "net.imglib2.type.numeric.integer.LongType"], - [name: "Uint64", type: "net.imglib2.type.numeric.integer.UnsignedLongType"], - [name: "Uint128", type: "net.imglib2.type.numeric.integer.Unsigned128BitType"], - [name: "Float32", type: "net.imglib2.type.numeric.real.FloatType"], - [name: "Float64", type: "net.imglib2.type.numeric.real.DoubleType"], -// [name: "Cfloat32", type: "net.imglib2.type.numeric.complex.ComplexFloatType"], -// [name: "Cfloat64", type: "net.imglib2.type.numeric.complex.ComplexDoubleType"], -] -``` +[ConvertImagesTest.java] +ops = ``` +[ +// NB: Some tests disabled until ImgLib2 is updated in +// accordance with https://github.com/imglib/imglib2#111 + [name: "Bit", type: "net.imglib2.type.logic.BitType"], +// [name: "Uint2", type: "net.imglib2.type.numeric.integer.Unsigned2BitType"], +// [name: "Uint4", type: "net.imglib2.type.numeric.integer.Unsigned4BitType"], + [name: "Int8", type: "net.imglib2.type.numeric.integer.ByteType"], + [name: "Uint8", type: "net.imglib2.type.numeric.integer.UnsignedByteType"], +// [name: "Uint12", type: "net.imglib2.type.numeric.integer.Unsigned12BitType"], + [name: "Int16", type: "net.imglib2.type.numeric.integer.ShortType"], + [name: "Uint16", type: "net.imglib2.type.numeric.integer.UnsignedShortType"], + [name: "Int32", type: "net.imglib2.type.numeric.integer.IntType"], + [name: "Uint32", type: "net.imglib2.type.numeric.integer.UnsignedIntType"], + [name: "Int64", type: "net.imglib2.type.numeric.integer.LongType"], + [name: "Uint64", type: "net.imglib2.type.numeric.integer.UnsignedLongType"], + [name: "Uint128", type: "net.imglib2.type.numeric.integer.Unsigned128BitType"], + [name: "Float32", type: "net.imglib2.type.numeric.real.FloatType"], + [name: "Float64", type: "net.imglib2.type.numeric.real.DoubleType"], +// [name: "Cfloat32", type: "net.imglib2.type.numeric.complex.ComplexFloatType"], +// [name: "Cfloat64", type: "net.imglib2.type.numeric.complex.ComplexDoubleType"], +] +``` diff --git a/src/test/templates/net/imagej/ops/convert/TestConvertType.list b/src/test/templates/net/imagej/ops/convert/TestConvertType.list index f0305a5d22..e7f5ccd9ea 100644 --- a/src/test/templates/net/imagej/ops/convert/TestConvertType.list +++ b/src/test/templates/net/imagej/ops/convert/TestConvertType.list @@ -1,99 +1,99 @@ -# Unit tests for convert ops - -[TestConvertType.java] -biv = ``` -[ - [name: "p64", v: 'new BigInteger("17EF234567ABCD123", 16)'], - [name: "n64", v: 'new BigInteger("-1399890AB", 16)'], - [name: "beef", v: "BigInteger.valueOf(0xbeef)"], - [name: "biZero", v: "BigInteger.ZERO"], - [name: "p128", v: 'new BigInteger("2CAFE0321BEEF0717BABE0929DEAD0311", 16)'], - [name: "n128", v: 'new BigInteger("-482301498A285BFD0982EE7DE02398BC9080459284CCDE90E9F0D00C043981210481AAADEF2", 16)'] -] -``` - -types = ``` -[ - [op: "Bit", built: "bit", imglibT: "Bit", outMethod: "bit", values: [ - [v: "true", r: "1", i: "0"], - [v: "false", r: "0", i: "0"] - ]], - [op: "Uint2", built:"uint2", imglibT: "Unsigned2Bit", outMethod: "uint2", values: [ - [v: "2", r: "2", i: "0"], - [v: "0", r: "0", i: "0"] - ]], - [op: "Uint4", built: "uint4", imglibT: "Unsigned4Bit", outMethod: "uint4", values: [ - [v: "15", r: "15", i: "0"], - [v: "0", r: "0", i: "0"] - ]], - [op: "Int8", built: "int8", imglibT: "Byte", outMethod: "int8", values: [ - [v: "(byte) 8", r: "(byte) 8", i: "(byte) 0"], - [v: "(byte) 0", r: "(byte) 0", i: "(byte) 0"], - [v: "(byte) -12", r: "(byte) -12", i: "(byte) 0"] - ]], - [op: "Uint8", built: "uint8", imglibT: "UnsignedByte", outMethod: "uint8", values: [ - [v: "100", r: "100", i: "0"], - [v: "0", r: "0", i: "0"] - ]], - [op: "Uint12", built: "uint12", imglibT: "Unsigned12Bit", outMethod: "uint12", values: [ - [v: "212L", r: "212L", i: "0L"], - [v: "0L", r: "0L", i: "0L"] - ]], - [op: "Int16", built: "int16", imglibT: "Short", outMethod: "int16", values: [ - [v: "(short) 52", r: "(short) 52", i: "(short) 0"], - [v: "(short) 0", r: "(short) 0", i: "(short) 0"], - [v: "(short) -154", r: "(short) -154", i: "(short) 0"] - ]], - [op: "Uint16", built: "uint16", imglibT: "UnsignedShort", outMethod: "uint16", values: [ - [v: "480", r: "480", i: "0"], - [v: "0", r: "0", i: "0"] - ]], - [op: "Int32", built: "int32", imglibT: "Int", outMethod: "int32", values: [ - [v: "301", r: "301", i: "0"], - [v: "0", r: "0", i: "0"], - [v: "-89", r: "-89", i: "0"] - ]], - [op: "Uint32", built: "uint32", imglibT: "UnsignedInt", outMethod: "uint32", values: [ - [v: "20L", r: "20L", i: "0L"], - [v: "0L", r: "0L", i: "0L"] - ]], - [op: "Int64", built: "int64", imglibT: "Long", outMethod: "int64", values: [ - [v: "891L", r: "891L", i: "0L"], - [v: "0L", r: "0L", i: "0L"], - [v: "-1024L", r: "-1024L", i: "0L"] - ]], - [op: "Uint64", built: "uint64", imglibT: "UnsignedLong", outMethod: "uint64", values: [ - [v: "1049L", r: "1049L", i: "0L"], - [v: "0L", r: "0L", i: "0L"], - [v: "p64", r: "p64", i: "0L", s:""], - [v: "n64", r: "n64", i: "0L", s:""] - ]], - [op: "Uint128", built: "uint128", imglibT: "Unsigned128Bit", outMethod: "uint128", values: [ - [v: "beef", r: "beef", i: "biZero"], - [v: "biZero", r: "biZero", i: "biZero"], - [v: "p128", r: "p128", i: "biZero"], - [v: "n128", r: "n128", i: "biZero"] - ]], - [op: "Float32", built: "float32", imglibT: "Float", outMethod: "float32", values: [ - [v: "123453.125f", r: "123453.125f", i: "0f"], - [v: "0f", r: "0f", i: "0f"], - [v: "-2523485349058.0f", r: "-2523485349058.0f", i: "0f"] - ]], - [op: "Cfloat32", built: "cfloat32", imglibT: "ComplexFloat", outMethod: "float32", values: [ - [v: "5839.25f, 120f", r: "5839.25f", i: "120f"], - [v: "0f, 0f", r: "0f", i: "0f"], - [v: "-4.25f, -123.0625f", r: "-4.25f", i: "-123.0625f"] - ]], - [op: "Float64", built: "float64", imglibT: "Double", outMethod: "float64", values: [ - [v: "4098d", r: "4098d", i: "0d"], - [v: "0d", r: "0d", i: "0d"], - [v: "-10948.015625d", r: "-10948.015625d", i: "0d"], - [v: "1.0000152587890625e20", r: "1.0000152587890625e20", i: "0"] - ]], - [op: "Cfloat64", built: "cfloat64", imglibT: "ComplexDouble", outMethod: "float64", values: [ - [v: "9087d, 879542.125d", r: "9087d", i: "879542.125d"], - [v: "0d, 0d", r: "0d", i: "0d"], - [v: "-234.25d, -9.0d", r: "-234.25d", i: "-9.0d"] - ]] -] -``` +# Unit tests for convert ops + +[TestConvertType.java] +biv = ``` +[ + [name: "p64", v: 'new BigInteger("17EF234567ABCD123", 16)'], + [name: "n64", v: 'new BigInteger("-1399890AB", 16)'], + [name: "beef", v: "BigInteger.valueOf(0xbeef)"], + [name: "biZero", v: "BigInteger.ZERO"], + [name: "p128", v: 'new BigInteger("2CAFE0321BEEF0717BABE0929DEAD0311", 16)'], + [name: "n128", v: 'new BigInteger("-482301498A285BFD0982EE7DE02398BC9080459284CCDE90E9F0D00C043981210481AAADEF2", 16)'] +] +``` + +types = ``` +[ + [op: "Bit", built: "bit", imglibT: "Bit", outMethod: "bit", values: [ + [v: "true", r: "1", i: "0"], + [v: "false", r: "0", i: "0"] + ]], + [op: "Uint2", built:"uint2", imglibT: "Unsigned2Bit", outMethod: "uint2", values: [ + [v: "2", r: "2", i: "0"], + [v: "0", r: "0", i: "0"] + ]], + [op: "Uint4", built: "uint4", imglibT: "Unsigned4Bit", outMethod: "uint4", values: [ + [v: "15", r: "15", i: "0"], + [v: "0", r: "0", i: "0"] + ]], + [op: "Int8", built: "int8", imglibT: "Byte", outMethod: "int8", values: [ + [v: "(byte) 8", r: "(byte) 8", i: "(byte) 0"], + [v: "(byte) 0", r: "(byte) 0", i: "(byte) 0"], + [v: "(byte) -12", r: "(byte) -12", i: "(byte) 0"] + ]], + [op: "Uint8", built: "uint8", imglibT: "UnsignedByte", outMethod: "uint8", values: [ + [v: "100", r: "100", i: "0"], + [v: "0", r: "0", i: "0"] + ]], + [op: "Uint12", built: "uint12", imglibT: "Unsigned12Bit", outMethod: "uint12", values: [ + [v: "212L", r: "212L", i: "0L"], + [v: "0L", r: "0L", i: "0L"] + ]], + [op: "Int16", built: "int16", imglibT: "Short", outMethod: "int16", values: [ + [v: "(short) 52", r: "(short) 52", i: "(short) 0"], + [v: "(short) 0", r: "(short) 0", i: "(short) 0"], + [v: "(short) -154", r: "(short) -154", i: "(short) 0"] + ]], + [op: "Uint16", built: "uint16", imglibT: "UnsignedShort", outMethod: "uint16", values: [ + [v: "480", r: "480", i: "0"], + [v: "0", r: "0", i: "0"] + ]], + [op: "Int32", built: "int32", imglibT: "Int", outMethod: "int32", values: [ + [v: "301", r: "301", i: "0"], + [v: "0", r: "0", i: "0"], + [v: "-89", r: "-89", i: "0"] + ]], + [op: "Uint32", built: "uint32", imglibT: "UnsignedInt", outMethod: "uint32", values: [ + [v: "20L", r: "20L", i: "0L"], + [v: "0L", r: "0L", i: "0L"] + ]], + [op: "Int64", built: "int64", imglibT: "Long", outMethod: "int64", values: [ + [v: "891L", r: "891L", i: "0L"], + [v: "0L", r: "0L", i: "0L"], + [v: "-1024L", r: "-1024L", i: "0L"] + ]], + [op: "Uint64", built: "uint64", imglibT: "UnsignedLong", outMethod: "uint64", values: [ + [v: "1049L", r: "1049L", i: "0L"], + [v: "0L", r: "0L", i: "0L"], + [v: "p64", r: "p64", i: "0L", s:""], + [v: "n64", r: "n64", i: "0L", s:""] + ]], + [op: "Uint128", built: "uint128", imglibT: "Unsigned128Bit", outMethod: "uint128", values: [ + [v: "beef", r: "beef", i: "biZero"], + [v: "biZero", r: "biZero", i: "biZero"], + [v: "p128", r: "p128", i: "biZero"], + [v: "n128", r: "n128", i: "biZero"] + ]], + [op: "Float32", built: "float32", imglibT: "Float", outMethod: "float32", values: [ + [v: "123453.125f", r: "123453.125f", i: "0f"], + [v: "0f", r: "0f", i: "0f"], + [v: "-2523485349058.0f", r: "-2523485349058.0f", i: "0f"] + ]], + [op: "Cfloat32", built: "cfloat32", imglibT: "ComplexFloat", outMethod: "float32", values: [ + [v: "5839.25f, 120f", r: "5839.25f", i: "120f"], + [v: "0f, 0f", r: "0f", i: "0f"], + [v: "-4.25f, -123.0625f", r: "-4.25f", i: "-123.0625f"] + ]], + [op: "Float64", built: "float64", imglibT: "Double", outMethod: "float64", values: [ + [v: "4098d", r: "4098d", i: "0d"], + [v: "0d", r: "0d", i: "0d"], + [v: "-10948.015625d", r: "-10948.015625d", i: "0d"], + [v: "1.0000152587890625e20", r: "1.0000152587890625e20", i: "0"] + ]], + [op: "Cfloat64", built: "cfloat64", imglibT: "ComplexDouble", outMethod: "float64", values: [ + [v: "9087d, 879542.125d", r: "9087d", i: "879542.125d"], + [v: "0d, 0d", r: "0d", i: "0d"], + [v: "-234.25d, -9.0d", r: "-234.25d", i: "-9.0d"] + ]] +] +``` diff --git a/src/test/templates/net/imagej/ops/convert/TestConvertType.vm b/src/test/templates/net/imagej/ops/convert/TestConvertType.vm index 8ab8b56fca..e976cb75a5 100644 --- a/src/test/templates/net/imagej/ops/convert/TestConvertType.vm +++ b/src/test/templates/net/imagej/ops/convert/TestConvertType.vm @@ -1,129 +1,129 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.convert; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import java.math.BigInteger; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.type.logic.BitType; -import net.imglib2.type.numeric.complex.ComplexDoubleType; -import net.imglib2.type.numeric.complex.ComplexFloatType; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.integer.ShortType; -import net.imglib2.type.numeric.integer.Unsigned128BitType; -import net.imglib2.type.numeric.integer.Unsigned12BitType; -import net.imglib2.type.numeric.integer.Unsigned2BitType; -import net.imglib2.type.numeric.integer.Unsigned4BitType; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.type.numeric.integer.UnsignedIntType; -import net.imglib2.type.numeric.integer.UnsignedLongType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Test; - -/** - * Tests the {@link ConvertTypes} ops. - * - * @author Alison Walter - */ -public class TestConvertType extends AbstractOpTest{ - -#foreach ($bi in $biv) - private final BigInteger $bi.name = $bi.v; -#end - -#foreach ($toType in $types) -#set ($methodName = "Types.$toType.outMethod") -#set ($imgLibType = "$toType.imglibT" + "Type") -#if ($toType.op.equals("Cfloat32")) -#set ($getR = "getRealFloat()") -#set ($getI = "getImaginaryFloat()") -#else -#set ($getR = "getRealDouble()") -#set ($getI = "getImaginaryDouble()") -#end -#foreach ($fromType in $types) -#if ($fromType.built.contains("float") || $toType.built.contains("float")) -#set ($className = "ConvertTypes.ComplexTo$toType.op") -#else -#set ($className = "ConvertTypes.IntegerTo$toType.op") -#end -#set ($imgLibType2 = "$fromType.imglibT" + "Type") -#set ($first = "true") - /** Tests {@link $className}. */ - @Test - public void test${fromType.op}To${toType.op}() { - -#foreach ($value in ${fromType.values}) -#if ($first.equals("true")) - final $imgLibType2 b = new $imgLibType2($value.v); - final Object result = ops.run(${className}.class, b); - assertTrue(result instanceof $imgLibType); -#if($toType.op.contains("C")) - assertEquals($methodName($value.r), (($imgLibType) result).$getR, 0); - assertEquals($methodName($value.i), (($imgLibType) result).$getI, 0); -#elseif ($toType.op.contains("Float")) - assertEquals($methodName($value.r), (($imgLibType) result).get(), 0); -#elseif ($toType.op.equals("Uint64")) - assertEquals($methodName($value.r), (($imgLibType) result).getBigInteger()); -#else - assertEquals($methodName($value.r), (($imgLibType) result).get()); -#end -#set ($first = "false") -#else - b.set($value.v); -#if($toType.op.contains("C")) - assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).$getR, 0); - assertEquals($methodName($value.i), (($imgLibType) ops.run(${className}.class, b)).$getI, 0); -#elseif ($toType.op.contains("Float")) - assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).get(), 0); -#elseif ($toType.op.equals("Uint64")) - assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).getBigInteger()); -#elseif ($toType.op.equals("Uint128") && $fromType.op.equals("Uint64") && $value.s) - assertEquals(Types.uint64Uint128($value.r), (($imgLibType) ops.run(${className}.class, b)).getBigInteger()); -#else - assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).get()); -#end -#end - -#end - } - -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.convert; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import java.math.BigInteger; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.complex.ComplexDoubleType; +import net.imglib2.type.numeric.complex.ComplexFloatType; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.Unsigned128BitType; +import net.imglib2.type.numeric.integer.Unsigned12BitType; +import net.imglib2.type.numeric.integer.Unsigned2BitType; +import net.imglib2.type.numeric.integer.Unsigned4BitType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedLongType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Test; + +/** + * Tests the {@link ConvertTypes} ops. + * + * @author Alison Walter + */ +public class TestConvertType extends AbstractOpTest{ + +#foreach ($bi in $biv) + private final BigInteger $bi.name = $bi.v; +#end + +#foreach ($toType in $types) +#set ($methodName = "Types.$toType.outMethod") +#set ($imgLibType = "$toType.imglibT" + "Type") +#if ($toType.op.equals("Cfloat32")) +#set ($getR = "getRealFloat()") +#set ($getI = "getImaginaryFloat()") +#else +#set ($getR = "getRealDouble()") +#set ($getI = "getImaginaryDouble()") +#end +#foreach ($fromType in $types) +#if ($fromType.built.contains("float") || $toType.built.contains("float")) +#set ($className = "ConvertTypes.ComplexTo$toType.op") +#else +#set ($className = "ConvertTypes.IntegerTo$toType.op") +#end +#set ($imgLibType2 = "$fromType.imglibT" + "Type") +#set ($first = "true") + /** Tests {@link $className}. */ + @Test + public void test${fromType.op}To${toType.op}() { + +#foreach ($value in ${fromType.values}) +#if ($first.equals("true")) + final $imgLibType2 b = new $imgLibType2($value.v); + final Object result = ops.run(${className}.class, b); + assertTrue(result instanceof $imgLibType); +#if($toType.op.contains("C")) + assertEquals($methodName($value.r), (($imgLibType) result).$getR, 0); + assertEquals($methodName($value.i), (($imgLibType) result).$getI, 0); +#elseif ($toType.op.contains("Float")) + assertEquals($methodName($value.r), (($imgLibType) result).get(), 0); +#elseif ($toType.op.equals("Uint64")) + assertEquals($methodName($value.r), (($imgLibType) result).getBigInteger()); +#else + assertEquals($methodName($value.r), (($imgLibType) result).get()); +#end +#set ($first = "false") +#else + b.set($value.v); +#if($toType.op.contains("C")) + assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).$getR, 0); + assertEquals($methodName($value.i), (($imgLibType) ops.run(${className}.class, b)).$getI, 0); +#elseif ($toType.op.contains("Float")) + assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).get(), 0); +#elseif ($toType.op.equals("Uint64")) + assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).getBigInteger()); +#elseif ($toType.op.equals("Uint128") && $fromType.op.equals("Uint64") && $value.s) + assertEquals(Types.uint64Uint128($value.r), (($imgLibType) ops.run(${className}.class, b)).getBigInteger()); +#else + assertEquals($methodName($value.r), (($imgLibType) ops.run(${className}.class, b)).get()); +#end +#end + +#end + } + +#end +#end +} diff --git a/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.list b/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.list index 284edad840..eae07450aa 100644 --- a/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.list +++ b/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.list @@ -1,11 +1,11 @@ -# Unit tests for binary logic ops with IIs and RAIs and output to IIs. - -[IIToIIOutputIITest.java] - -ops = ``` -[ - [name: "And", function: "and"], - [name: "Or", function: "or"], - [name: "Xor", function: "xor"], -] -``` +# Unit tests for binary logic ops with IIs and RAIs and output to IIs. + +[IIToIIOutputIITest.java] + +ops = ``` +[ + [name: "And", function: "and"], + [name: "Or", function: "or"], + [name: "Xor", function: "xor"], +] +``` diff --git a/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.vm b/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.vm index c081a5a34c..7541aede7c 100644 --- a/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.vm +++ b/src/test/templates/net/imagej/ops/logic/IIToIIOutputIITest.vm @@ -1,82 +1,82 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.logic.BitType; - -import org.junit.Before; -import org.junit.Test; - -public class IIToIIOutputIITest extends AbstractOpTest { - - private Img in1; - private Img in2; - - @Before - public void initImg() { - final boolean[] in1Data = { true, true, false, false }; - final boolean[] in2Data = { true, false, true, false }; - in1 = ArrayImgs.bits(2, 2); - in2 = ArrayImgs.bits(2, 2); - final Cursor c1 = in1.cursor(); - final Cursor c2 = in2.cursor(); - for (int i = 0; i < 4; i++) { - c1.next().set(in1Data[i]); - c2.next().set(in2Data[i]); - } - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - @SuppressWarnings("unchecked") - final IterableInterval out = (IterableInterval) ops.run( - IIToIIOutputII.And.class, in1, in2); - final Cursor in1Cursor = in1.cursor(); - final Cursor in2Cursor = in2.cursor(); - final Cursor outCursor = out.cursor(); - final BitType result = new BitType(); - while (in1Cursor.hasNext()) { - result.set(in1Cursor.next()); - result.and(in2Cursor.next()); - assertEquals(result.get(), outCursor.next().get()); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.logic.BitType; + +import org.junit.Before; +import org.junit.Test; + +public class IIToIIOutputIITest extends AbstractOpTest { + + private Img in1; + private Img in2; + + @Before + public void initImg() { + final boolean[] in1Data = { true, true, false, false }; + final boolean[] in2Data = { true, false, true, false }; + in1 = ArrayImgs.bits(2, 2); + in2 = ArrayImgs.bits(2, 2); + final Cursor c1 = in1.cursor(); + final Cursor c2 = in2.cursor(); + for (int i = 0; i < 4; i++) { + c1.next().set(in1Data[i]); + c2.next().set(in2Data[i]); + } + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + @SuppressWarnings("unchecked") + final IterableInterval out = (IterableInterval) ops.run( + IIToIIOutputII.And.class, in1, in2); + final Cursor in1Cursor = in1.cursor(); + final Cursor in2Cursor = in2.cursor(); + final Cursor outCursor = out.cursor(); + final BitType result = new BitType(); + while (in1Cursor.hasNext()) { + result.set(in1Cursor.next()); + result.and(in2Cursor.next()); + assertEquals(result.get(), outCursor.next().get()); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.list b/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.list index d07a99370c..f101354715 100644 --- a/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.list +++ b/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.list @@ -1,12 +1,12 @@ -# Unit tests for binary logic ops with IterableIntervals and output to -# IterableIntervals. - -[IIToRAIOutputIITest.java] - -ops = ``` -[ - [name: "And", function: "and"], - [name: "Or", function: "or"], - [name: "Xor", function: "xor"], -] -``` +# Unit tests for binary logic ops with IterableIntervals and output to +# IterableIntervals. + +[IIToRAIOutputIITest.java] + +ops = ``` +[ + [name: "And", function: "and"], + [name: "Or", function: "or"], + [name: "Xor", function: "xor"], +] +``` diff --git a/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.vm b/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.vm index 6fddb5a84e..c17f2cd7de 100644 --- a/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.vm +++ b/src/test/templates/net/imagej/ops/logic/IIToRAIOutputIITest.vm @@ -1,82 +1,82 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.logic.BitType; - -import org.junit.Before; -import org.junit.Test; - -public class IIToRAIOutputIITest extends AbstractOpTest { - - private Img in1; - private Img in2; - - @Before - public void initImg() { - final boolean[] in1Data = { true, true, false, false }; - final boolean[] in2Data = { true, false, true, false }; - in1 = ArrayImgs.bits(2, 2); - in2 = ArrayImgs.bits(2, 2); - final Cursor c1 = in1.cursor(); - final Cursor c2 = in2.cursor(); - for (int i = 0; i < 4; i++) { - c1.next().set(in1Data[i]); - c2.next().set(in2Data[i]); - } - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - @SuppressWarnings("unchecked") - final IterableInterval out = (IterableInterval) ops.run( - IIToRAIOutputII.And.class, in1, in2); - final Cursor in1Cursor = in1.cursor(); - final Cursor in2Cursor = in2.cursor(); - final Cursor outCursor = out.cursor(); - final BitType result = new BitType(); - while (in1Cursor.hasNext()) { - result.set(in1Cursor.next()); - result.and(in2Cursor.next()); - assertEquals(result.get(), outCursor.next().get()); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.logic.BitType; + +import org.junit.Before; +import org.junit.Test; + +public class IIToRAIOutputIITest extends AbstractOpTest { + + private Img in1; + private Img in2; + + @Before + public void initImg() { + final boolean[] in1Data = { true, true, false, false }; + final boolean[] in2Data = { true, false, true, false }; + in1 = ArrayImgs.bits(2, 2); + in2 = ArrayImgs.bits(2, 2); + final Cursor c1 = in1.cursor(); + final Cursor c2 = in2.cursor(); + for (int i = 0; i < 4; i++) { + c1.next().set(in1Data[i]); + c2.next().set(in2Data[i]); + } + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + @SuppressWarnings("unchecked") + final IterableInterval out = (IterableInterval) ops.run( + IIToRAIOutputII.And.class, in1, in2); + final Cursor in1Cursor = in1.cursor(); + final Cursor in2Cursor = in2.cursor(); + final Cursor outCursor = out.cursor(); + final BitType result = new BitType(); + while (in1Cursor.hasNext()) { + result.set(in1Cursor.next()); + result.and(in2Cursor.next()); + assertEquals(result.get(), outCursor.next().get()); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.list b/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.list index fa2613d56d..8c715f25a7 100644 --- a/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.list +++ b/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.list @@ -1,97 +1,97 @@ -# Unit tests for the unary and binary logical ops with primitive args. - -[PrimitiveLogicTest.java] -types = ``` -[ - B: [name: "Boolean", primitive: "boolean"], - D: [name: "Double", primitive: "double"], - F: [name: "Float", primitive: "float"], - I: [name: "Integer", primitive: "int"], - L: [name: "Long", primitive: "long"] -] -``` -tests = ``` -[ - [op: "And", code: "B", result: "false", args: "false, false"], - [op: "And", code: "B", result: "false", args: "false, true"], - [op: "And", code: "B", result: "false", args: "true, false"], - [op: "And", code: "B", result: "true", args: "true, true"], - - [op: "GreaterThan", code: "I", result: "true", args: "2, 1"], - [op: "GreaterThan", code: "I", result: "false", args: "2, 2"], - [op: "GreaterThan", code: "I", result: "false", args: "2, 3"], - - [op: "GreaterThan", code: "L", result: "true", args: "5L, 4L"], - [op: "GreaterThan", code: "L", result: "false", args: "5L, 5L"], - [op: "GreaterThan", code: "L", result: "false", args: "5L, 6L"], - - [op: "GreaterThan", code: "F", result: "true", args: "8f, 7f"], - [op: "GreaterThan", code: "F", result: "false", args: "8f, 8f"], - [op: "GreaterThan", code: "F", result: "false", args: "8f, 9f"], - - [op: "GreaterThan", code: "D", result: "true", args: "11d, 10d"], - [op: "GreaterThan", code: "D", result: "false", args: "11d, 11d"], - [op: "GreaterThan", code: "D", result: "false", args: "11d, 12d"], - - [op: "GreaterThanOrEqual", code: "I", result: "true", args: "2, 1"], - [op: "GreaterThanOrEqual", code: "I", result: "true", args: "2, 2"], - [op: "GreaterThanOrEqual", code: "I", result: "false", args: "2, 3"], - - [op: "GreaterThanOrEqual", code: "L", result: "true", args: "5L, 4L"], - [op: "GreaterThanOrEqual", code: "L", result: "true", args: "5L, 5L"], - [op: "GreaterThanOrEqual", code: "L", result: "false", args: "5L, 6L"], - - [op: "GreaterThanOrEqual", code: "F", result: "true", args: "8f, 7f"], - [op: "GreaterThanOrEqual", code: "F", result: "true", args: "8f, 8f"], - [op: "GreaterThanOrEqual", code: "F", result: "false", args: "8f, 9f"], - - [op: "GreaterThanOrEqual", code: "D", result: "true", args: "11d, 10d"], - [op: "GreaterThanOrEqual", code: "D", result: "true", args: "11d, 11d"], - [op: "GreaterThanOrEqual", code: "D", result: "false", args: "11d, 12d"], - - [op: "LessThan", code: "I", result: "false", args: "2, 1"], - [op: "LessThan", code: "I", result: "false", args: "2, 2"], - [op: "LessThan", code: "I", result: "true", args: "2, 3"], - - [op: "LessThan", code: "L", result: "false", args: "5L, 4L"], - [op: "LessThan", code: "L", result: "false", args: "5L, 5L"], - [op: "LessThan", code: "L", result: "true", args: "5L, 6L"], - - [op: "LessThan", code: "F", result: "false", args: "8f, 7f"], - [op: "LessThan", code: "F", result: "false", args: "8f, 8f"], - [op: "LessThan", code: "F", result: "true", args: "8f, 9f"], - - [op: "LessThan", code: "D", result: "false", args: "11d, 10d"], - [op: "LessThan", code: "D", result: "false", args: "11d, 11d"], - [op: "LessThan", code: "D", result: "true", args: "11d, 12d"], - - [op: "LessThanOrEqual", code: "I", result: "false", args: "2, 1"], - [op: "LessThanOrEqual", code: "I", result: "true", args: "2, 2"], - [op: "LessThanOrEqual", code: "I", result: "true", args: "2, 3"], - - [op: "LessThanOrEqual", code: "L", result: "false", args: "5L, 4L"], - [op: "LessThanOrEqual", code: "L", result: "true", args: "5L, 5L"], - [op: "LessThanOrEqual", code: "L", result: "true", args: "5L, 6L"], - - [op: "LessThanOrEqual", code: "F", result: "false", args: "8f, 7f"], - [op: "LessThanOrEqual", code: "F", result: "true", args: "8f, 8f"], - [op: "LessThanOrEqual", code: "F", result: "true", args: "8f, 9f"], - - [op: "LessThanOrEqual", code: "D", result: "false", args: "11d, 10d"], - [op: "LessThanOrEqual", code: "D", result: "true", args: "11d, 11d"], - [op: "LessThanOrEqual", code: "D", result: "true", args: "11d, 12d"], - - [op: "Not", code: "B", result: "true", args: "false"], - [op: "Not", code: "B", result: "false", args: "true"], - - [op: "Or", code: "B", result: "false", args: "false, false"], - [op: "Or", code: "B", result: "true", args: "false, true"], - [op: "Or", code: "B", result: "true", args: "true, false"], - [op: "Or", code: "B", result: "true", args: "true, true"], - - [op: "Xor", code: "B", result: "false", args: "false, false"], - [op: "Xor", code: "B", result: "true", args: "false, true"], - [op: "Xor", code: "B", result: "true", args: "true, false"], - [op: "Xor", code: "B", result: "false", args: "true, true"] -] -``` +# Unit tests for the unary and binary logical ops with primitive args. + +[PrimitiveLogicTest.java] +types = ``` +[ + B: [name: "Boolean", primitive: "boolean"], + D: [name: "Double", primitive: "double"], + F: [name: "Float", primitive: "float"], + I: [name: "Integer", primitive: "int"], + L: [name: "Long", primitive: "long"] +] +``` +tests = ``` +[ + [op: "And", code: "B", result: "false", args: "false, false"], + [op: "And", code: "B", result: "false", args: "false, true"], + [op: "And", code: "B", result: "false", args: "true, false"], + [op: "And", code: "B", result: "true", args: "true, true"], + + [op: "GreaterThan", code: "I", result: "true", args: "2, 1"], + [op: "GreaterThan", code: "I", result: "false", args: "2, 2"], + [op: "GreaterThan", code: "I", result: "false", args: "2, 3"], + + [op: "GreaterThan", code: "L", result: "true", args: "5L, 4L"], + [op: "GreaterThan", code: "L", result: "false", args: "5L, 5L"], + [op: "GreaterThan", code: "L", result: "false", args: "5L, 6L"], + + [op: "GreaterThan", code: "F", result: "true", args: "8f, 7f"], + [op: "GreaterThan", code: "F", result: "false", args: "8f, 8f"], + [op: "GreaterThan", code: "F", result: "false", args: "8f, 9f"], + + [op: "GreaterThan", code: "D", result: "true", args: "11d, 10d"], + [op: "GreaterThan", code: "D", result: "false", args: "11d, 11d"], + [op: "GreaterThan", code: "D", result: "false", args: "11d, 12d"], + + [op: "GreaterThanOrEqual", code: "I", result: "true", args: "2, 1"], + [op: "GreaterThanOrEqual", code: "I", result: "true", args: "2, 2"], + [op: "GreaterThanOrEqual", code: "I", result: "false", args: "2, 3"], + + [op: "GreaterThanOrEqual", code: "L", result: "true", args: "5L, 4L"], + [op: "GreaterThanOrEqual", code: "L", result: "true", args: "5L, 5L"], + [op: "GreaterThanOrEqual", code: "L", result: "false", args: "5L, 6L"], + + [op: "GreaterThanOrEqual", code: "F", result: "true", args: "8f, 7f"], + [op: "GreaterThanOrEqual", code: "F", result: "true", args: "8f, 8f"], + [op: "GreaterThanOrEqual", code: "F", result: "false", args: "8f, 9f"], + + [op: "GreaterThanOrEqual", code: "D", result: "true", args: "11d, 10d"], + [op: "GreaterThanOrEqual", code: "D", result: "true", args: "11d, 11d"], + [op: "GreaterThanOrEqual", code: "D", result: "false", args: "11d, 12d"], + + [op: "LessThan", code: "I", result: "false", args: "2, 1"], + [op: "LessThan", code: "I", result: "false", args: "2, 2"], + [op: "LessThan", code: "I", result: "true", args: "2, 3"], + + [op: "LessThan", code: "L", result: "false", args: "5L, 4L"], + [op: "LessThan", code: "L", result: "false", args: "5L, 5L"], + [op: "LessThan", code: "L", result: "true", args: "5L, 6L"], + + [op: "LessThan", code: "F", result: "false", args: "8f, 7f"], + [op: "LessThan", code: "F", result: "false", args: "8f, 8f"], + [op: "LessThan", code: "F", result: "true", args: "8f, 9f"], + + [op: "LessThan", code: "D", result: "false", args: "11d, 10d"], + [op: "LessThan", code: "D", result: "false", args: "11d, 11d"], + [op: "LessThan", code: "D", result: "true", args: "11d, 12d"], + + [op: "LessThanOrEqual", code: "I", result: "false", args: "2, 1"], + [op: "LessThanOrEqual", code: "I", result: "true", args: "2, 2"], + [op: "LessThanOrEqual", code: "I", result: "true", args: "2, 3"], + + [op: "LessThanOrEqual", code: "L", result: "false", args: "5L, 4L"], + [op: "LessThanOrEqual", code: "L", result: "true", args: "5L, 5L"], + [op: "LessThanOrEqual", code: "L", result: "true", args: "5L, 6L"], + + [op: "LessThanOrEqual", code: "F", result: "false", args: "8f, 7f"], + [op: "LessThanOrEqual", code: "F", result: "true", args: "8f, 8f"], + [op: "LessThanOrEqual", code: "F", result: "true", args: "8f, 9f"], + + [op: "LessThanOrEqual", code: "D", result: "false", args: "11d, 10d"], + [op: "LessThanOrEqual", code: "D", result: "true", args: "11d, 11d"], + [op: "LessThanOrEqual", code: "D", result: "true", args: "11d, 12d"], + + [op: "Not", code: "B", result: "true", args: "false"], + [op: "Not", code: "B", result: "false", args: "true"], + + [op: "Or", code: "B", result: "false", args: "false, false"], + [op: "Or", code: "B", result: "true", args: "false, true"], + [op: "Or", code: "B", result: "true", args: "true, false"], + [op: "Or", code: "B", result: "true", args: "true, true"], + + [op: "Xor", code: "B", result: "false", args: "false, false"], + [op: "Xor", code: "B", result: "true", args: "false, true"], + [op: "Xor", code: "B", result: "true", args: "true, false"], + [op: "Xor", code: "B", result: "false", args: "true, true"] +] +``` diff --git a/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.vm b/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.vm index 4d37d856a9..ed73f9d578 100644 --- a/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.vm +++ b/src/test/templates/net/imagej/ops/logic/PrimitiveLogicTest.vm @@ -1,63 +1,63 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.logic; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import net.imagej.ops.AbstractOpTest; - -import org.junit.Test; - -/** - * Tests the {@link PrimitiveLogic} ops. - * - * @author Curtis Rueden - */ -public class PrimitiveLogicTest extends AbstractOpTest { -#set ($id = 0) -#foreach ($test in $tests) -#if ($types.containsKey($test.code)) -#set ($type = $types.get($test.code)) -#set ($className = "$type.name$test.op") -#set ($id = $id + 1) - - /** Tests {@link PrimitiveLogic.$className}. */ - @Test - public void test$id$className() { - final Object result = ops.run(PrimitiveLogic.${className}.class, $test.args); - assertTrue(result instanceof Boolean); - final boolean value = (Boolean) result; - assertEquals($test.result, value); - } -#end -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.logic; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import net.imagej.ops.AbstractOpTest; + +import org.junit.Test; + +/** + * Tests the {@link PrimitiveLogic} ops. + * + * @author Curtis Rueden + */ +public class PrimitiveLogicTest extends AbstractOpTest { +#set ($id = 0) +#foreach ($test in $tests) +#if ($types.containsKey($test.code)) +#set ($type = $types.get($test.code)) +#set ($className = "$type.name$test.op") +#set ($id = $id + 1) + + /** Tests {@link PrimitiveLogic.$className}. */ + @Test + public void test$id$className() { + final Object result = ops.run(PrimitiveLogic.${className}.class, $test.args); + assertTrue(result instanceof Boolean); + final boolean value = (Boolean) result; + assertEquals($test.result, value); + } +#end +#end + +} diff --git a/src/test/templates/net/imagej/ops/map/MapBinaryComputersTest.list b/src/test/templates/net/imagej/ops/map/MapBinaryComputersTest.list index 0c60918469..4d87019fbe 100644 --- a/src/test/templates/net/imagej/ops/map/MapBinaryComputersTest.list +++ b/src/test/templates/net/imagej/ops/map/MapBinaryComputersTest.list @@ -1,7 +1,7 @@ -# Generate tests for MapBinaryComputers - -[MapBinaryComputersTest.java] - -types = ``` -["II", "RAI"] -``` +# Generate tests for MapBinaryComputers + +[MapBinaryComputersTest.java] + +types = ``` +["II", "RAI"] +``` diff --git a/src/test/templates/net/imagej/ops/map/MapBinaryInplace1sTest.list b/src/test/templates/net/imagej/ops/map/MapBinaryInplace1sTest.list index 28b531cfb2..8f5d41fd55 100644 --- a/src/test/templates/net/imagej/ops/map/MapBinaryInplace1sTest.list +++ b/src/test/templates/net/imagej/ops/map/MapBinaryInplace1sTest.list @@ -1,7 +1,7 @@ -# Generate tests for MapBinaryInplace1s. - -[MapBinaryInplace1sTest.java] - -types = ``` -["II", "RAI"] -``` +# Generate tests for MapBinaryInplace1s. + +[MapBinaryInplace1sTest.java] + +types = ``` +["II", "RAI"] +``` diff --git a/src/test/templates/net/imagej/ops/map/MapUnaryComputersTest.list b/src/test/templates/net/imagej/ops/map/MapUnaryComputersTest.list index ffbdbd2c78..6abe2c913e 100644 --- a/src/test/templates/net/imagej/ops/map/MapUnaryComputersTest.list +++ b/src/test/templates/net/imagej/ops/map/MapUnaryComputersTest.list @@ -1,7 +1,7 @@ -# Generate tests for MapUnaryComputers - -[MapUnaryComputersTest.java] - -types = ``` -["II", "RAI"] -``` +# Generate tests for MapUnaryComputers + +[MapUnaryComputersTest.java] + +types = ``` +["II", "RAI"] +``` diff --git a/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.list b/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.list index 5f1f496667..fa2c3686ab 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.list +++ b/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.list @@ -1,22 +1,22 @@ -# Unit tests for binary arithmetic ops with ArrayImages and their parallelized version. - -[ConstantToArrayImageTest.java] - -types = ``` -[ - [name: "Byte", primitive: "byte"], - [name: "Int", primitive: "int"], - [name: "Long", primitive: "long"], - [name: "Float", primitive: "float"], - [name: "Double", primitive: "double"] -] -``` - -ops = ``` -[ - [name: "Add", operator: "+"], - [name: "Subtract", operator: "-"], - [name: "Multiply", operator: "*"], - [name: "Divide", operator: "/"] -] -``` +# Unit tests for binary arithmetic ops with ArrayImages and their parallelized version. + +[ConstantToArrayImageTest.java] + +types = ``` +[ + [name: "Byte", primitive: "byte"], + [name: "Int", primitive: "int"], + [name: "Long", primitive: "long"], + [name: "Float", primitive: "float"], + [name: "Double", primitive: "double"] +] +``` + +ops = ``` +[ + [name: "Add", operator: "+"], + [name: "Subtract", operator: "-"], + [name: "Multiply", operator: "*"], + [name: "Divide", operator: "/"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.vm b/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.vm index 00a6ef1fed..d2d11ab6bf 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.vm +++ b/src/test/templates/net/imagej/ops/math/ConstantToArrayImageTest.vm @@ -1,80 +1,80 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.img.Img; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Test; - -public class ConstantToArrayImageTest extends AbstractOpTest { - -#foreach ($type in $types) -#set ($imglibType = $type.name + "Type") -#set ($isByte = $type.name == "Byte") -#set ($isFloat = $type.name == "Float" || $type.name == "Double") - private ${type.primitive}[] get${type.name}Array() { - return new ${type.primitive}[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }; - } - -#foreach ($op in $ops) -#set ($className = $op.name + $type.name) - @Test - public void test${className}() { - final Img<$imglibType> in = ArrayImgs.${type.primitive}s(get${type.name}Array(), 3, 3); - final Img<$imglibType> copy = in.copy(); - final ${type.primitive} constant = 3; - ops.run(ConstantToArrayImage.${className}.class, in, constant); - final Cursor<$imglibType> inCursor = in.cursor(); - final Cursor<$imglibType> copyCursor = copy.cursor(); - while (inCursor.hasNext()) { - assertEquals(inCursor.next().get(), #if ($isByte)(byte) #{end}(copyCursor.next().get() $op.operator constant)#if ($isFloat), 0.0#{end}); - } - ops.run(ConstantToArrayImageP.${className}.class, copy, constant); - inCursor.reset(); - copyCursor.reset(); - while (inCursor.hasNext()) { - assertEquals(inCursor.next().get(), copyCursor.next().get()#if ($isFloat), 0.0#{end}); - } - } - -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Test; + +public class ConstantToArrayImageTest extends AbstractOpTest { + +#foreach ($type in $types) +#set ($imglibType = $type.name + "Type") +#set ($isByte = $type.name == "Byte") +#set ($isFloat = $type.name == "Float" || $type.name == "Double") + private ${type.primitive}[] get${type.name}Array() { + return new ${type.primitive}[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }; + } + +#foreach ($op in $ops) +#set ($className = $op.name + $type.name) + @Test + public void test${className}() { + final Img<$imglibType> in = ArrayImgs.${type.primitive}s(get${type.name}Array(), 3, 3); + final Img<$imglibType> copy = in.copy(); + final ${type.primitive} constant = 3; + ops.run(ConstantToArrayImage.${className}.class, in, constant); + final Cursor<$imglibType> inCursor = in.cursor(); + final Cursor<$imglibType> copyCursor = copy.cursor(); + while (inCursor.hasNext()) { + assertEquals(inCursor.next().get(), #if ($isByte)(byte) #{end}(copyCursor.next().get() $op.operator constant)#if ($isFloat), 0.0#{end}); + } + ops.run(ConstantToArrayImageP.${className}.class, copy, constant); + inCursor.reset(); + copyCursor.reset(); + while (inCursor.hasNext()) { + assertEquals(inCursor.next().get(), copyCursor.next().get()#if ($isFloat), 0.0#{end}); + } + } + +#end +#end +} diff --git a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.list b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.list index d371b1b90d..836890ddc9 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.list +++ b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.list @@ -1,12 +1,12 @@ -# Unit tests for functional binary arithmetic ops with II as both input and output. - -[ConstantToIIOutputIITest.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Unit tests for functional binary arithmetic ops with II as both input and output. + +[ConstantToIIOutputIITest.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.vm b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.vm index cebc0f034b..bcc6ea8732 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.vm +++ b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputIITest.vm @@ -1,81 +1,81 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Before; -import org.junit.Test; - -public class ConstantToIIOutputIITest extends AbstractOpTest { - - final private FloatType constant = new FloatType(3.0f); - private Img in; - private Img copy; - private Img out; - - @Before - public void initImg() { - in = generateFloatArrayTestImg(true, 3, 3); - copy = in.copy(); - out = generateFloatArrayTestImg(false, 3, 3); - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - @SuppressWarnings("unchecked") - final ConstantToIIOutputII.${op.name} op = ops.op( - ConstantToIIOutputII.${op.name}.class, out, in, constant); - op.run(); - final IterableInterval created = op.calculate(in); - op.mutate(in); - final Cursor inCursor = in.cursor(); - final Cursor copyCursor = copy.cursor(); - final Cursor outCursor = out.cursor(); - final Cursor crtCursor = created.cursor(); - while (inCursor.hasNext()) { - copyCursor.next().${op.function}(constant); - final float expected = copyCursor.get().get(); - assertEquals(inCursor.next().get(), expected, 0.0); - assertEquals(outCursor.next().get(), expected, 0.0); - assertEquals(crtCursor.next().get(), expected, 0.0); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Before; +import org.junit.Test; + +public class ConstantToIIOutputIITest extends AbstractOpTest { + + final private FloatType constant = new FloatType(3.0f); + private Img in; + private Img copy; + private Img out; + + @Before + public void initImg() { + in = generateFloatArrayTestImg(true, 3, 3); + copy = in.copy(); + out = generateFloatArrayTestImg(false, 3, 3); + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + @SuppressWarnings("unchecked") + final ConstantToIIOutputII.${op.name} op = ops.op( + ConstantToIIOutputII.${op.name}.class, out, in, constant); + op.run(); + final IterableInterval created = op.calculate(in); + op.mutate(in); + final Cursor inCursor = in.cursor(); + final Cursor copyCursor = copy.cursor(); + final Cursor outCursor = out.cursor(); + final Cursor crtCursor = created.cursor(); + while (inCursor.hasNext()) { + copyCursor.next().${op.function}(constant); + final float expected = copyCursor.get().get(); + assertEquals(inCursor.next().get(), expected, 0.0); + assertEquals(outCursor.next().get(), expected, 0.0); + assertEquals(crtCursor.next().get(), expected, 0.0); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.list b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.list index 9bb6243d1d..415ac02203 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.list +++ b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.list @@ -1,12 +1,12 @@ -# Unit tests for functional binary arithmetic ops with II as input and RAI as output. - -[ConstantToIIOutputRAITest.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Unit tests for functional binary arithmetic ops with II as input and RAI as output. + +[ConstantToIIOutputRAITest.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.vm b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.vm index 3a840d2ec6..020a3ecf1b 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.vm +++ b/src/test/templates/net/imagej/ops/math/ConstantToIIOutputRAITest.vm @@ -1,68 +1,68 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.img.Img; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Before; -import org.junit.Test; - -public class ConstantToIIOutputRAITest extends AbstractOpTest { - - final private FloatType constant = new FloatType(3.0f); - private Img in; - private Img out; - - @Before - public void initImg() { - in = generateFloatArrayTestImg(true, 3, 3); - out = generateFloatArrayTestImg(false, 3, 3); - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - ops.run(ConstantToIIOutputRAI.${op.name}.class, out, in, constant); - final Cursor inCursor = in.cursor(); - final Cursor outCursor = out.cursor(); - while (inCursor.hasNext()) { - inCursor.next().${op.function}(constant); - assertEquals(outCursor.next().get(), inCursor.get().get(), 0.0); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.img.Img; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Before; +import org.junit.Test; + +public class ConstantToIIOutputRAITest extends AbstractOpTest { + + final private FloatType constant = new FloatType(3.0f); + private Img in; + private Img out; + + @Before + public void initImg() { + in = generateFloatArrayTestImg(true, 3, 3); + out = generateFloatArrayTestImg(false, 3, 3); + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + ops.run(ConstantToIIOutputRAI.${op.name}.class, out, in, constant); + final Cursor inCursor = in.cursor(); + final Cursor outCursor = out.cursor(); + while (inCursor.hasNext()) { + inCursor.next().${op.function}(constant); + assertEquals(outCursor.next().get(), inCursor.get().get(), 0.0); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.list b/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.list index a6eace7c54..3ace5bb989 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.list +++ b/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.list @@ -1,22 +1,22 @@ -# Unit tests for binary arithmetic ops with PlanarImages. - -[ConstantToPlanarImageTest.java] - -types = ``` -[ - [name: "Byte", primitive: "byte"], - [name: "Int", primitive: "int"], - [name: "Long", primitive: "long"], - [name: "Float", primitive: "float"], - [name: "Double", primitive: "double"] -] -``` - -ops = ``` -[ - [name: "Add", operator: "+"], - [name: "Subtract", operator: "-"], - [name: "Multiply", operator: "*"], - [name: "Divide", operator: "/"], -] -``` +# Unit tests for binary arithmetic ops with PlanarImages. + +[ConstantToPlanarImageTest.java] + +types = ``` +[ + [name: "Byte", primitive: "byte"], + [name: "Int", primitive: "int"], + [name: "Long", primitive: "long"], + [name: "Float", primitive: "float"], + [name: "Double", primitive: "double"] +] +``` + +ops = ``` +[ + [name: "Add", operator: "+"], + [name: "Subtract", operator: "-"], + [name: "Multiply", operator: "*"], + [name: "Divide", operator: "/"], +] +``` diff --git a/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.vm b/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.vm index a6d7467477..5a0516a74f 100644 --- a/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.vm +++ b/src/test/templates/net/imagej/ops/math/ConstantToPlanarImageTest.vm @@ -1,78 +1,78 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.img.Img; -import net.imglib2.img.planar.PlanarImgs; -import net.imglib2.type.numeric.integer.ByteType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Test; - -public class ConstantToPlanarImageTest extends AbstractOpTest { - -#foreach ($type in $types) -#set ($imglibType = $type.name + "Type") -#set ($isByte = $type.name == "Byte") -#set ($isFloat = $type.name == "Float" || $type.name == "Double") - private Img<$imglibType> get${type.name}PlanarImg() { - final Img<$imglibType> img = PlanarImgs.${type.primitive}s(3, 3); - $type.primitive i = 11; - for ($imglibType px : img) - px.set(i++); - return img; - } - -#foreach ($op in $ops) -#set ($className = $op.name + $type.name) - @Test - public void test${className}() { - final Img<$imglibType> in = get${type.name}PlanarImg(); - final Img<$imglibType> copy = in.copy(); - final $type.primitive constant = 3; - ops.run(ConstantToPlanarImage.${className}.class, in, constant); - final Cursor<$imglibType> inCursor = in.cursor(); - final Cursor<$imglibType> copyCursor = copy.cursor(); - while (inCursor.hasNext()) { - assertEquals(inCursor.next().get(), #if ($isByte)(byte) #{end}(copyCursor.next().get() $op.operator constant)#if ($isFloat), 0.0#{end}); - } - } - -#end -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.img.Img; +import net.imglib2.img.planar.PlanarImgs; +import net.imglib2.type.numeric.integer.ByteType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Test; + +public class ConstantToPlanarImageTest extends AbstractOpTest { + +#foreach ($type in $types) +#set ($imglibType = $type.name + "Type") +#set ($isByte = $type.name == "Byte") +#set ($isFloat = $type.name == "Float" || $type.name == "Double") + private Img<$imglibType> get${type.name}PlanarImg() { + final Img<$imglibType> img = PlanarImgs.${type.primitive}s(3, 3); + $type.primitive i = 11; + for ($imglibType px : img) + px.set(i++); + return img; + } + +#foreach ($op in $ops) +#set ($className = $op.name + $type.name) + @Test + public void test${className}() { + final Img<$imglibType> in = get${type.name}PlanarImg(); + final Img<$imglibType> copy = in.copy(); + final $type.primitive constant = 3; + ops.run(ConstantToPlanarImage.${className}.class, in, constant); + final Cursor<$imglibType> inCursor = in.cursor(); + final Cursor<$imglibType> copyCursor = copy.cursor(); + while (inCursor.hasNext()) { + assertEquals(inCursor.next().get(), #if ($isByte)(byte) #{end}(copyCursor.next().get() $op.operator constant)#if ($isFloat), 0.0#{end}); + } + } + +#end +#end +} diff --git a/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.list b/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.list index 7570eff9d3..504b039c60 100644 --- a/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.list +++ b/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.list @@ -1,12 +1,12 @@ -# Unit tests for binary arithmetic ops with IIs and RAIs and output to IIs. - -[IIToIIOutputIITest.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Unit tests for binary arithmetic ops with IIs and RAIs and output to IIs. + +[IIToIIOutputIITest.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.vm b/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.vm index 86569a1095..9a556a8c5f 100644 --- a/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.vm +++ b/src/test/templates/net/imagej/ops/math/IIToIIOutputIITest.vm @@ -1,85 +1,85 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Before; -import org.junit.Test; - -public class IIToIIOutputIITest extends AbstractOpTest { - - private Img in1; - private Img in2; - private Img copy1; - private Img out; - - @Before - public void initImg() { - in1 = generateFloatArrayTestImg(true, 3, 3); - in2 = ArrayImgs.floats(new float[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }, - 3, 3); - copy1 = in1.copy(); - out = ArrayImgs.floats(3, 3); - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - @SuppressWarnings("unchecked") - final IIToRAIOutputII.${op.name} op = ops.op(IIToRAIOutputII.${op.name}.class, - out, in1, in2); - op.run(); - final IterableInterval created = op.calculate(in1, in2); - op.mutate(in1); - final Cursor in1Cursor = in1.cursor(); - final Cursor copy1Cursor = copy1.cursor(); - final Cursor in2Cursor = in2.cursor(); - final Cursor outCursor = out.cursor(); - final Cursor crtCursor = created.cursor(); - while (copy1Cursor.hasNext()) { - copy1Cursor.next().${op.function}(in2Cursor.next()); - final float expected = copy1Cursor.get().get(); - assertEquals(in1Cursor.next().get(), expected, 0.0); - assertEquals(outCursor.next().get(), expected, 0.0); - assertEquals(crtCursor.next().get(), expected, 0.0); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Before; +import org.junit.Test; + +public class IIToIIOutputIITest extends AbstractOpTest { + + private Img in1; + private Img in2; + private Img copy1; + private Img out; + + @Before + public void initImg() { + in1 = generateFloatArrayTestImg(true, 3, 3); + in2 = ArrayImgs.floats(new float[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }, + 3, 3); + copy1 = in1.copy(); + out = ArrayImgs.floats(3, 3); + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + @SuppressWarnings("unchecked") + final IIToRAIOutputII.${op.name} op = ops.op(IIToRAIOutputII.${op.name}.class, + out, in1, in2); + op.run(); + final IterableInterval created = op.calculate(in1, in2); + op.mutate(in1); + final Cursor in1Cursor = in1.cursor(); + final Cursor copy1Cursor = copy1.cursor(); + final Cursor in2Cursor = in2.cursor(); + final Cursor outCursor = out.cursor(); + final Cursor crtCursor = created.cursor(); + while (copy1Cursor.hasNext()) { + copy1Cursor.next().${op.function}(in2Cursor.next()); + final float expected = copy1Cursor.get().get(); + assertEquals(in1Cursor.next().get(), expected, 0.0); + assertEquals(outCursor.next().get(), expected, 0.0); + assertEquals(crtCursor.next().get(), expected, 0.0); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.list b/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.list index 1089461511..38f7e7d3e6 100644 --- a/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.list +++ b/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.list @@ -1,13 +1,13 @@ -# Unit tests for binary arithmetic ops with IterableIntervals and output to -# IterableIntervals. - -[IIToRAIOutputIITest.java] - -ops = ``` -[ - [name: "Add", function: "add"], - [name: "Subtract", function: "sub"], - [name: "Multiply", function: "mul"], - [name: "Divide", function: "div"] -] -``` +# Unit tests for binary arithmetic ops with IterableIntervals and output to +# IterableIntervals. + +[IIToRAIOutputIITest.java] + +ops = ``` +[ + [name: "Add", function: "add"], + [name: "Subtract", function: "sub"], + [name: "Multiply", function: "mul"], + [name: "Divide", function: "div"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.vm b/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.vm index 9e9ae12b52..97a9fa571a 100644 --- a/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.vm +++ b/src/test/templates/net/imagej/ops/math/IIToRAIOutputIITest.vm @@ -1,87 +1,87 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; - -import net.imagej.ops.AbstractOpTest; -import net.imglib2.Cursor; -import net.imglib2.IterableInterval; -import net.imglib2.img.Img; -import net.imglib2.img.array.ArrayImgs; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Before; -import org.junit.Test; - -public class IIToRAIOutputIITest extends AbstractOpTest { - - private Img in1; - private Img in2; - private Img copy1; - private Img copy2; - private Img out; - - @Before - public void initImg() { - in1 = generateFloatArrayTestImg(true, 3, 3); - in2 = ArrayImgs.floats(new float[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }, - 3, 3); - copy1 = in1.copy(); - copy2 = in2.copy(); - out = ArrayImgs.floats(3, 3); - } - -#foreach ($op in $ops) - @Test - public void test${op.name}() { - @SuppressWarnings("unchecked") - final IIToRAIOutputII.${op.name} op = ops.op(IIToRAIOutputII.${op.name}.class, - out, in1, in2); - op.run(); - final IterableInterval created = op.calculate(in1, in2); - op.mutate(in1); - final Cursor in1Cursor = in1.cursor(); - final Cursor copy1Cursor = copy1.cursor(); - final Cursor copy2Cursor = copy2.cursor(); - final Cursor outCursor = out.cursor(); - final Cursor crtCursor = created.cursor(); - while (copy1Cursor.hasNext()) { - copy1Cursor.next().${op.function}(copy2Cursor.next()); - final float expected = copy1Cursor.get().get(); - assertEquals(in1Cursor.next().get(), expected, 0.0); - assertEquals(outCursor.next().get(), expected, 0.0); - assertEquals(crtCursor.next().get(), expected, 0.0); - } - } - -#end -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; + +import net.imagej.ops.AbstractOpTest; +import net.imglib2.Cursor; +import net.imglib2.IterableInterval; +import net.imglib2.img.Img; +import net.imglib2.img.array.ArrayImgs; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Before; +import org.junit.Test; + +public class IIToRAIOutputIITest extends AbstractOpTest { + + private Img in1; + private Img in2; + private Img copy1; + private Img copy2; + private Img out; + + @Before + public void initImg() { + in1 = generateFloatArrayTestImg(true, 3, 3); + in2 = ArrayImgs.floats(new float[] { 11, 12, 13, 14, 15, 16, 17, 18, 19 }, + 3, 3); + copy1 = in1.copy(); + copy2 = in2.copy(); + out = ArrayImgs.floats(3, 3); + } + +#foreach ($op in $ops) + @Test + public void test${op.name}() { + @SuppressWarnings("unchecked") + final IIToRAIOutputII.${op.name} op = ops.op(IIToRAIOutputII.${op.name}.class, + out, in1, in2); + op.run(); + final IterableInterval created = op.calculate(in1, in2); + op.mutate(in1); + final Cursor in1Cursor = in1.cursor(); + final Cursor copy1Cursor = copy1.cursor(); + final Cursor copy2Cursor = copy2.cursor(); + final Cursor outCursor = out.cursor(); + final Cursor crtCursor = created.cursor(); + while (copy1Cursor.hasNext()) { + copy1Cursor.next().${op.function}(copy2Cursor.next()); + final float expected = copy1Cursor.get().get(); + assertEquals(in1Cursor.next().get(), expected, 0.0); + assertEquals(outCursor.next().get(), expected, 0.0); + assertEquals(crtCursor.next().get(), expected, 0.0); + } + } + +#end +} diff --git a/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.list b/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.list index ef238f90b0..0716197102 100644 --- a/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.list +++ b/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.list @@ -1,29 +1,29 @@ -# Unit tests for the binary arithmetic ops with ImgLib2 NumericTypes. - -[NumericTypeBinaryMathTest.java] -types = ``` -[ - "BitType", - "DoubleType", - "FloatType", - "IntType", - "LongType", - "ShortType", - "UnboundedIntegerType", - "Unsigned12BitType", - "Unsigned2BitType", - "Unsigned4BitType", - "UnsignedByteType", - "UnsignedIntType", - "UnsignedShortType" -] -``` - -tests = ``` -[ - [op: "Add", function: "add"], - [op: "Subtract", function: "sub"], - [op: "Multiply", function: "mul"], - [op: "Divide", function: "div"] -] -``` +# Unit tests for the binary arithmetic ops with ImgLib2 NumericTypes. + +[NumericTypeBinaryMathTest.java] +types = ``` +[ + "BitType", + "DoubleType", + "FloatType", + "IntType", + "LongType", + "ShortType", + "UnboundedIntegerType", + "Unsigned12BitType", + "Unsigned2BitType", + "Unsigned4BitType", + "UnsignedByteType", + "UnsignedIntType", + "UnsignedShortType" +] +``` + +tests = ``` +[ + [op: "Add", function: "add"], + [op: "Subtract", function: "sub"], + [op: "Multiply", function: "mul"], + [op: "Divide", function: "div"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.vm b/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.vm index 72d9f70405..f962b98194 100644 --- a/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.vm +++ b/src/test/templates/net/imagej/ops/math/NumericTypeBinaryMathTest.vm @@ -1,87 +1,87 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; -import net.imagej.ops.AbstractOpTest; -import net.imagej.types.UnboundedIntegerType; -import net.imglib2.type.logic.BitType; -import net.imglib2.type.numeric.integer.IntType; -import net.imglib2.type.numeric.integer.LongType; -import net.imglib2.type.numeric.integer.ShortType; -import net.imglib2.type.numeric.integer.Unsigned12BitType; -import net.imglib2.type.numeric.integer.Unsigned2BitType; -import net.imglib2.type.numeric.integer.Unsigned4BitType; -import net.imglib2.type.numeric.integer.UnsignedByteType; -import net.imglib2.type.numeric.integer.UnsignedIntType; -import net.imglib2.type.numeric.integer.UnsignedShortType; -import net.imglib2.type.numeric.real.DoubleType; -import net.imglib2.type.numeric.real.FloatType; - -import org.junit.Test; - -/** - * Tests the {@link NumericTypeBinaryMath} ops. - * - * @author Aparna Pal - * @author Curtis Rueden - */ -public class NumericTypeBinaryMathTest extends AbstractOpTest { - - final double aValue = 6.0; - final double bValue = 2.0; -#foreach ($test in $tests) -#set ($className = "NumericTypeBinaryMath.$test.op") -#foreach ($type in $types) -#set ($methodName = $test.op.substring(0, 1).toLowerCase() + $test.op.substring(1)) - - /** Tests {@link $className} with {@link $type} arguments. */ - @Test - public void test${test.op}${type}() { - final $type a = new ${type}(); - final $type b = new ${type}(); - a.setReal(aValue); - b.setReal(bValue); - final $type expected = new ${type}(); - expected.set(a); - expected.${test.function}(b); - final Object result = ops.run(${className}.class, a, b); - final $type actual = ($type) result; -## NB: Compare values, until all types implement equals properly. -## assertEquals(expected, actual); - final Object expectedObj = expected.get(); - final Object actualObj = actual.get(); - assertEquals(expectedObj, actualObj); - } -#end -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; +import net.imagej.ops.AbstractOpTest; +import net.imagej.types.UnboundedIntegerType; +import net.imglib2.type.logic.BitType; +import net.imglib2.type.numeric.integer.IntType; +import net.imglib2.type.numeric.integer.LongType; +import net.imglib2.type.numeric.integer.ShortType; +import net.imglib2.type.numeric.integer.Unsigned12BitType; +import net.imglib2.type.numeric.integer.Unsigned2BitType; +import net.imglib2.type.numeric.integer.Unsigned4BitType; +import net.imglib2.type.numeric.integer.UnsignedByteType; +import net.imglib2.type.numeric.integer.UnsignedIntType; +import net.imglib2.type.numeric.integer.UnsignedShortType; +import net.imglib2.type.numeric.real.DoubleType; +import net.imglib2.type.numeric.real.FloatType; + +import org.junit.Test; + +/** + * Tests the {@link NumericTypeBinaryMath} ops. + * + * @author Aparna Pal + * @author Curtis Rueden + */ +public class NumericTypeBinaryMathTest extends AbstractOpTest { + + final double aValue = 6.0; + final double bValue = 2.0; +#foreach ($test in $tests) +#set ($className = "NumericTypeBinaryMath.$test.op") +#foreach ($type in $types) +#set ($methodName = $test.op.substring(0, 1).toLowerCase() + $test.op.substring(1)) + + /** Tests {@link $className} with {@link $type} arguments. */ + @Test + public void test${test.op}${type}() { + final $type a = new ${type}(); + final $type b = new ${type}(); + a.setReal(aValue); + b.setReal(bValue); + final $type expected = new ${type}(); + expected.set(a); + expected.${test.function}(b); + final Object result = ops.run(${className}.class, a, b); + final $type actual = ($type) result; +## NB: Compare values, until all types implement equals properly. +## assertEquals(expected, actual); + final Object expectedObj = expected.get(); + final Object actualObj = actual.get(); + assertEquals(expectedObj, actualObj); + } +#end +#end + +} diff --git a/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.list b/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.list index 44c24ce632..e56e014de7 100644 --- a/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.list +++ b/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.list @@ -1,103 +1,103 @@ -# Unit tests for the unary and binary arithmetic ops with primitive args. - -[PrimitiveMathTest.java] -types = ``` -[ - D: [name: "Double", primitive: "double", delta: "0.0"], - F: [name: "Float", primitive: "float", delta: "0f"], - I: [name: "Integer", primitive: "int"], - L: [name: "Long", primitive: "long"] -] -``` -tests = ``` -[ - [op: "Add", code: "D", result: "3.0", args: "1.0, 2.0"], - [op: "Add", code: "F", result: "8f", args: "3f, 5f"], - [op: "Add", code: "I", result: "-7", args: "11, -18"], - [op: "Add", code: "L", result: "1111111111111111110L", args: "123456789987654321L, 987654321123456789L"], - - [op: "Subtract", code: "D", result: "-1.0", args: "1.0, 2.0"], - [op: "Subtract", code: "F", result: "2f", args: "5f, 3f"], - [op: "Subtract", code: "I", result: "31", args: "12, -19"], - [op: "Subtract", code: "L", result: "864197531135802468L", args: "987654321123456789L, 123456789987654321L"], - - [op: "Multiply", code: "D", result: "8.4", args: "2.4, 3.5"], - [op: "Multiply", code: "F", result: "15.84f", args: "4.4f, 3.6f"], - [op: "Multiply", code: "I", result: "-6", args: "2, -3"], - [op: "Multiply", code: "L", result: "8747884673140948462L", args: "1234567887654321L, 8765432112345678L"], - - [op: "Divide", code: "D", result: "2.0e11", args: "2.2e34, 1.1e23"], - [op: "Divide", code: "F", result: "1.375f", args: "4.4f, 3.2f"], - [op: "Divide", code: "I", result: "3", args: "11, 3"], - [op: "Divide", code: "L", result: "80000L", args: "987654321123456789L, 12345677654321L"], - - [op: "Remainder", code: "D", result: "5.914556415807146e120", args: "2.2e234, 1.1e123"], - [op: "Remainder", code: "F", result: "2.5f", args: "9.3f, 3.4f"], - [op: "Remainder", code: "I", result: "2", args: "11, 3"], - [op: "Remainder", code: "L", result: "108777776789L", args: "987654321123456789L, 12345677654321L"], - - [op: "And", code: "I", result: "0xcaacbaae", args: "0xcafebabe, 0xdeadbeef"], - [op: "And", code: "L", result: "0x9eadbabecaac8aeeL", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], - - [op: "Or", code: "I", result: "0xdeffbeff", args: "0xcafebabe, 0xdeadbeef"], - [op: "Or", code: "L", result: "0xfeefbabedefffeffL", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], - - [op: "Xor", code: "I", result: "0x14530451", args: "0xcafebabe, 0xdeadbeef"], - [op: "Xor", code: "L", result: "0x6042000014537411L", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], - [op: "LeftShift", code: "I", result: "0x5d5f0000", args: "0xcafebabe, 15"], - [op: "LeftShift", code: "L", result: "0x6f56e57f00000000L", args: "0xbeefbabedeadcafeL, 31"], - - [op: "RightShift", code: "I", result: "0xffff95fd", args: "0xcafebabe, 15"], - [op: "RightShift", code: "L", result: "0xffffffff7ddf757dL", args: "0xbeefbabedeadcafeL, 31"], - - [op: "UnsignedRightShift", code: "I", result: "0x195fd", args: "0xcafebabe, 15"], - [op: "UnsignedRightShift", code: "L", result: "0x17ddf757dL", args: "0xbeefbabedeadcafeL, 31"], - - [op: "Max", code: "D", result: "1.6", args: "1.6, 1.55"], - [op: "Max", code: "F", result: "-3.2f", args: "-4.8f, -3.2f"], - [op: "Max", code: "I", result: "8", args: "3, 8"], - [op: "Max", code: "L", result: "987654321123456789L", args: "123456789987654321L, 987654321123456789L"], - - [op: "Min", code: "D", result: "1.55", args: "1.6, 1.55"], - [op: "Min", code: "F", result: "-4.8f", args: "-4.8f, -3.2f"], - [op: "Min", code: "I", result: "11", args: "11, 571"], - [op: "Min", code: "L", result: "123456789987654321L", args: "123456789987654321L, 987654321123456789L"], - - [op: "Power", code: "D", result: "8.0", args: "2.0, 3.0"], - - [op: "Negate", code: "D", result: "-3.0", args: "3.0"], - [op: "Negate", code: "F", result: "3f", args: "-3f"], - [op: "Negate", code: "I", result: "-3", args: "3"], - [op: "Negate", code: "L", result: "123456789987654321L", args: "-123456789987654321L"], - - [op: "Abs", code: "D", result: "2.0", args: "-2.0"], - [op: "Abs", code: "F", result: "2f", args: "-2f"], - [op: "Abs", code: "I", result: "2", args: "-2"], - [op: "Abs", code: "L", result: "123456789987654321L", args: "-123456789987654321L"], - - [op: "Arccos", code: "D", result: "0.6599873293874984", args: "0.79"], - [op: "Arcsin", code: "D", result: "0.9108089974073983", args: "0.79"], - [op: "Arctan", code: "D", result: "0.6686135679278209", args: "0.79"], - [op: "Ceil", code: "D", result: "1.0", args: "0.79"], - [op: "Cos", code: "D", result: "0.7038453156522361", args: "0.79"], - [op: "Cosh", code: "D", result: "1.3286206107691463", args: "0.79"], - [op: "CubeRoot", code: "D", result: "0.9244335465376482", args: "0.79"], - [op: "Exp", code: "D", result: "2.203396426255937", args: "0.79"], - [op: "Floor", code: "D", result: "0.0", args: "0.79"], - [op: "Log", code: "D", result: "-0.23572233352106983", args: "0.79"], - [op: "Log10", code: "D", result: "-0.10237290870955855", args: "0.79"], - [op: "LogOnePlusX", code: "D", result: "0.5822156198526637", args: "0.79"], - - [op: "Round", code: "D", result: "1.0", args: "0.79"], - [op: "Round", code: "F", result: "2f", args: "1.57f"], - - [op: "Signum", code: "D", result: "1.0", args: "0.79"], - [op: "Signum", code: "F", result: "-1f", args: "-4.56f"], - - [op: "Sin", code: "D", result: "0.7103532724176078", args: "0.79"], - [op: "Sinh", code: "D", result: "0.8747758154867904", args: "0.79"], - [op: "Sqrt", code: "D", result: "0.8888194417315589", args: "0.79"], - [op: "Tan", code: "D", result: "1.0092462883827549", args: "0.79"], - [op: "Tanh", code: "D", result: "0.6584090359552511", args: "0.79"] -] -``` +# Unit tests for the unary and binary arithmetic ops with primitive args. + +[PrimitiveMathTest.java] +types = ``` +[ + D: [name: "Double", primitive: "double", delta: "0.0"], + F: [name: "Float", primitive: "float", delta: "0f"], + I: [name: "Integer", primitive: "int"], + L: [name: "Long", primitive: "long"] +] +``` +tests = ``` +[ + [op: "Add", code: "D", result: "3.0", args: "1.0, 2.0"], + [op: "Add", code: "F", result: "8f", args: "3f, 5f"], + [op: "Add", code: "I", result: "-7", args: "11, -18"], + [op: "Add", code: "L", result: "1111111111111111110L", args: "123456789987654321L, 987654321123456789L"], + + [op: "Subtract", code: "D", result: "-1.0", args: "1.0, 2.0"], + [op: "Subtract", code: "F", result: "2f", args: "5f, 3f"], + [op: "Subtract", code: "I", result: "31", args: "12, -19"], + [op: "Subtract", code: "L", result: "864197531135802468L", args: "987654321123456789L, 123456789987654321L"], + + [op: "Multiply", code: "D", result: "8.4", args: "2.4, 3.5"], + [op: "Multiply", code: "F", result: "15.84f", args: "4.4f, 3.6f"], + [op: "Multiply", code: "I", result: "-6", args: "2, -3"], + [op: "Multiply", code: "L", result: "8747884673140948462L", args: "1234567887654321L, 8765432112345678L"], + + [op: "Divide", code: "D", result: "2.0e11", args: "2.2e34, 1.1e23"], + [op: "Divide", code: "F", result: "1.375f", args: "4.4f, 3.2f"], + [op: "Divide", code: "I", result: "3", args: "11, 3"], + [op: "Divide", code: "L", result: "80000L", args: "987654321123456789L, 12345677654321L"], + + [op: "Remainder", code: "D", result: "5.914556415807146e120", args: "2.2e234, 1.1e123"], + [op: "Remainder", code: "F", result: "2.5f", args: "9.3f, 3.4f"], + [op: "Remainder", code: "I", result: "2", args: "11, 3"], + [op: "Remainder", code: "L", result: "108777776789L", args: "987654321123456789L, 12345677654321L"], + + [op: "And", code: "I", result: "0xcaacbaae", args: "0xcafebabe, 0xdeadbeef"], + [op: "And", code: "L", result: "0x9eadbabecaac8aeeL", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], + + [op: "Or", code: "I", result: "0xdeffbeff", args: "0xcafebabe, 0xdeadbeef"], + [op: "Or", code: "L", result: "0xfeefbabedefffeffL", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], + + [op: "Xor", code: "I", result: "0x14530451", args: "0xcafebabe, 0xdeadbeef"], + [op: "Xor", code: "L", result: "0x6042000014537411L", args: "0xdeadbabecafebeefL, 0xbeefbabedeadcafeL"], + [op: "LeftShift", code: "I", result: "0x5d5f0000", args: "0xcafebabe, 15"], + [op: "LeftShift", code: "L", result: "0x6f56e57f00000000L", args: "0xbeefbabedeadcafeL, 31"], + + [op: "RightShift", code: "I", result: "0xffff95fd", args: "0xcafebabe, 15"], + [op: "RightShift", code: "L", result: "0xffffffff7ddf757dL", args: "0xbeefbabedeadcafeL, 31"], + + [op: "UnsignedRightShift", code: "I", result: "0x195fd", args: "0xcafebabe, 15"], + [op: "UnsignedRightShift", code: "L", result: "0x17ddf757dL", args: "0xbeefbabedeadcafeL, 31"], + + [op: "Max", code: "D", result: "1.6", args: "1.6, 1.55"], + [op: "Max", code: "F", result: "-3.2f", args: "-4.8f, -3.2f"], + [op: "Max", code: "I", result: "8", args: "3, 8"], + [op: "Max", code: "L", result: "987654321123456789L", args: "123456789987654321L, 987654321123456789L"], + + [op: "Min", code: "D", result: "1.55", args: "1.6, 1.55"], + [op: "Min", code: "F", result: "-4.8f", args: "-4.8f, -3.2f"], + [op: "Min", code: "I", result: "11", args: "11, 571"], + [op: "Min", code: "L", result: "123456789987654321L", args: "123456789987654321L, 987654321123456789L"], + + [op: "Power", code: "D", result: "8.0", args: "2.0, 3.0"], + + [op: "Negate", code: "D", result: "-3.0", args: "3.0"], + [op: "Negate", code: "F", result: "3f", args: "-3f"], + [op: "Negate", code: "I", result: "-3", args: "3"], + [op: "Negate", code: "L", result: "123456789987654321L", args: "-123456789987654321L"], + + [op: "Abs", code: "D", result: "2.0", args: "-2.0"], + [op: "Abs", code: "F", result: "2f", args: "-2f"], + [op: "Abs", code: "I", result: "2", args: "-2"], + [op: "Abs", code: "L", result: "123456789987654321L", args: "-123456789987654321L"], + + [op: "Arccos", code: "D", result: "0.6599873293874984", args: "0.79"], + [op: "Arcsin", code: "D", result: "0.9108089974073983", args: "0.79"], + [op: "Arctan", code: "D", result: "0.6686135679278209", args: "0.79"], + [op: "Ceil", code: "D", result: "1.0", args: "0.79"], + [op: "Cos", code: "D", result: "0.7038453156522361", args: "0.79"], + [op: "Cosh", code: "D", result: "1.3286206107691463", args: "0.79"], + [op: "CubeRoot", code: "D", result: "0.9244335465376482", args: "0.79"], + [op: "Exp", code: "D", result: "2.203396426255937", args: "0.79"], + [op: "Floor", code: "D", result: "0.0", args: "0.79"], + [op: "Log", code: "D", result: "-0.23572233352106983", args: "0.79"], + [op: "Log10", code: "D", result: "-0.10237290870955855", args: "0.79"], + [op: "LogOnePlusX", code: "D", result: "0.5822156198526637", args: "0.79"], + + [op: "Round", code: "D", result: "1.0", args: "0.79"], + [op: "Round", code: "F", result: "2f", args: "1.57f"], + + [op: "Signum", code: "D", result: "1.0", args: "0.79"], + [op: "Signum", code: "F", result: "-1f", args: "-4.56f"], + + [op: "Sin", code: "D", result: "0.7103532724176078", args: "0.79"], + [op: "Sinh", code: "D", result: "0.8747758154867904", args: "0.79"], + [op: "Sqrt", code: "D", result: "0.8888194417315589", args: "0.79"], + [op: "Tan", code: "D", result: "1.0092462883827549", args: "0.79"], + [op: "Tanh", code: "D", result: "0.6584090359552511", args: "0.79"] +] +``` diff --git a/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.vm b/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.vm index 5b83d96223..e66952088c 100644 --- a/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.vm +++ b/src/test/templates/net/imagej/ops/math/PrimitiveMathTest.vm @@ -1,66 +1,66 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison, University of Konstanz and Brian Northan. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.math; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import net.imagej.ops.AbstractOpTest; - -import org.junit.Test; - -/** - * Tests the {@link PrimitiveMath} ops. - * - * @author Curtis Rueden - */ -public class PrimitiveMathTest extends AbstractOpTest { -#foreach ($test in $tests) -#if ($types.containsKey($test.code)) -#set ($type = $types.get($test.code)) -#set ($className = "$type.name$test.op") -#set ($methodName = $test.op.substring(0, 1).toLowerCase() + $test.op.substring(1)) - - /** Tests {@link PrimitiveMath.$className}. */ - @Test - public void test$className() { - final Object result = ops.run(PrimitiveMath.${className}.class, $test.args); - assertTrue(result instanceof $type.name); - final $type.primitive value = ($type.name) result; -#if ($type.delta) - assertEquals($test.result, value, $type.delta); -#else - assertEquals($test.result, value); -#end - } -#end -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison, University of Konstanz and Brian Northan. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.math; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import net.imagej.ops.AbstractOpTest; + +import org.junit.Test; + +/** + * Tests the {@link PrimitiveMath} ops. + * + * @author Curtis Rueden + */ +public class PrimitiveMathTest extends AbstractOpTest { +#foreach ($test in $tests) +#if ($types.containsKey($test.code)) +#set ($type = $types.get($test.code)) +#set ($className = "$type.name$test.op") +#set ($methodName = $test.op.substring(0, 1).toLowerCase() + $test.op.substring(1)) + + /** Tests {@link PrimitiveMath.$className}. */ + @Test + public void test$className() { + final Object result = ops.run(PrimitiveMath.${className}.class, $test.args); + assertTrue(result instanceof $type.name); + final $type.primitive value = ($type.name) result; +#if ($type.delta) + assertEquals($test.result, value, $type.delta); +#else + assertEquals($test.result, value); +#end + } +#end +#end + +} diff --git a/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.list b/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.list index e6956036a8..d5e4335378 100644 --- a/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.list +++ b/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.list @@ -1,22 +1,22 @@ -[ComputeThresholdTest.java] -methods = ``` -[ - [name: "huang", iface: "Huang", expected: 36874], - [name: "ij1", iface: "IJ1", expected: 31836], - [name: "intermodes", iface: "Intermodes", expected: 34859], - [name: "isoData", iface: "IsoData", expected: 33095], - [name: "li", iface: "Li", expected: 26798], - [name: "maxEntropy", iface: "MaxEntropy", expected: 28309], - [name: "maxLikelihood", iface: "MaxLikelihood", expected: 46698], - [name: "mean", iface: "Mean", expected: 32591], - [name: "minError", iface: "MinError", expected: 32843], - [name: "minimum", iface: "Minimum", expected: 44935], - [name: "moments", iface: "Moments", expected: 34355], - [name: "otsu", iface: "Otsu", expected: 34103], - [name: "percentile", iface: "Percentile", expected: 32088], - [name: "renyiEntropy", iface: "RenyiEntropy", expected: 26546], - [name: "shanbhag", iface: "Shanbhag", expected: 27553], - [name: "triangle", iface: "Triangle", expected: 34607], - [name: "yen", iface: "Yen", expected: 24531] -] -``` +[ComputeThresholdTest.java] +methods = ``` +[ + [name: "huang", iface: "Huang", expected: 36874], + [name: "ij1", iface: "IJ1", expected: 31836], + [name: "intermodes", iface: "Intermodes", expected: 34859], + [name: "isoData", iface: "IsoData", expected: 33095], + [name: "li", iface: "Li", expected: 26798], + [name: "maxEntropy", iface: "MaxEntropy", expected: 28309], + [name: "maxLikelihood", iface: "MaxLikelihood", expected: 46698], + [name: "mean", iface: "Mean", expected: 32591], + [name: "minError", iface: "MinError", expected: 32843], + [name: "minimum", iface: "Minimum", expected: 44935], + [name: "moments", iface: "Moments", expected: 34355], + [name: "otsu", iface: "Otsu", expected: 34103], + [name: "percentile", iface: "Percentile", expected: 32088], + [name: "renyiEntropy", iface: "RenyiEntropy", expected: 26546], + [name: "shanbhag", iface: "Shanbhag", expected: 27553], + [name: "triangle", iface: "Triangle", expected: 34607], + [name: "yen", iface: "Yen", expected: 24531] +] +``` diff --git a/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.vm b/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.vm index ec36e3ee8f..d8cee03e0b 100644 --- a/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.vm +++ b/src/test/templates/net/imagej/ops/threshold/ComputeThresholdTest.vm @@ -1,53 +1,53 @@ -/* - * #%L - * ImageJ software for multidimensional image processing and analysis. - * %% - * Copyright (C) 2014 - 2016 Board of Regents of the University of - * Wisconsin-Madison and University of Konstanz. - * %% - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * #L% - */ - -package net.imagej.ops.threshold; - -import org.junit.Test; - -/** - * Tests {@link ComputeThresholdHistogram} implementations. - * - * @author Brian Northan - * @author Curtis Rueden - */ -public class ComputeThresholdTest extends AbstractThresholdTest { -#foreach ($method in $methods) -#set ($className = "net.imagej.ops.threshold.${method.name}.Compute${method.iface}Threshold") - - /** Tests {@link $className}. */ - @Test - public void test${method.iface}() { - final Object actual = ops.run(${className}.class, histogram()); - assertThreshold($method.expected, actual); - } -#end - -} +/* + * #%L + * ImageJ software for multidimensional image processing and analysis. + * %% + * Copyright (C) 2014 - 2016 Board of Regents of the University of + * Wisconsin-Madison and University of Konstanz. + * %% + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * #L% + */ + +package net.imagej.ops.threshold; + +import org.junit.Test; + +/** + * Tests {@link ComputeThresholdHistogram} implementations. + * + * @author Brian Northan + * @author Curtis Rueden + */ +public class ComputeThresholdTest extends AbstractThresholdTest { +#foreach ($method in $methods) +#set ($className = "net.imagej.ops.threshold.${method.name}.Compute${method.iface}Threshold") + + /** Tests {@link $className}. */ + @Test + public void test${method.iface}() { + final Object actual = ops.run(${className}.class, histogram()); + assertThreshold($method.expected, actual); + } +#end + +}