net.imglib2.img.basictypeaccess.array.ShortArray Java Examples

The following examples show how to use net.imglib2.img.basictypeaccess.array.ShortArray. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToArrayImageP.MultiplyShort.class,
	net.imagej.ops.math.ConstantToArrayImage.MultiplyShort.class,
	net.imagej.ops.math.ConstantToArrayImageP.MultiplyUnsignedShort.class,
	net.imagej.ops.math.ConstantToArrayImage.MultiplyUnsignedShort.class })
public <S extends GenericShortType<S>> ArrayImg<S, ShortArray> multiply(
	final ArrayImg<S, ShortArray> image, final short value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<S, ShortArray> result = (ArrayImg<S, ShortArray>) ops().run(
		Ops.Math.Multiply.NAME, image, value);
	return result;
}
 
Example #2
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = { net.imagej.ops.math.ConstantToPlanarImage.AddShort.class,
	net.imagej.ops.math.ConstantToPlanarImage.AddUnsignedShort.class })
public <S extends GenericShortType<S>> PlanarImg<S, ShortArray> add(
	final PlanarImg<S, ShortArray> arg, final short value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<S, ShortArray> result = (PlanarImg<S, ShortArray>) ops()
		.run(Ops.Math.Add.NAME, arg, value);
	return result;
}
 
Example #3
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.DivideShort.class,
	net.imagej.ops.math.ConstantToArrayImage.DivideShort.class,
	net.imagej.ops.math.ConstantToArrayImageP.DivideUnsignedShort.class,
	net.imagej.ops.math.ConstantToArrayImage.DivideUnsignedShort.class })
public <S extends GenericShortType<S>> ArrayImg<S, ShortArray> divide(
	final ArrayImg<S, ShortArray> image, final short value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<S, ShortArray> result = (ArrayImg<S, ShortArray>) ops().run(
		Ops.Math.Divide.NAME, image, value);
	return result;
}
 
Example #4
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = { net.imagej.ops.math.ConstantToPlanarImage.DivideShort.class,
	net.imagej.ops.math.ConstantToPlanarImage.DivideUnsignedShort.class })
public <S extends GenericShortType<S>> PlanarImg<S, ShortArray> divide(
	final PlanarImg<S, ShortArray> arg, final short value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<S, ShortArray> result = (PlanarImg<S, ShortArray>) ops()
		.run(Ops.Math.Divide.NAME, arg, value);
	return result;
}
 
Example #5
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = { net.imagej.ops.math.ConstantToArrayImageP.AddShort.class,
	net.imagej.ops.math.ConstantToArrayImage.AddShort.class,
	net.imagej.ops.math.ConstantToArrayImageP.AddUnsignedShort.class,
	net.imagej.ops.math.ConstantToArrayImage.AddUnsignedShort.class })
public <S extends GenericShortType<S>> ArrayImg<S, ShortArray> add(
	final ArrayImg<S, ShortArray> image, final short value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<S, ShortArray> result = (ArrayImg<S, ShortArray>) ops().run(
		Ops.Math.Add.NAME, image, value);
	return result;
}
 
Example #6
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToPlanarImage.MultiplyShort.class,
	net.imagej.ops.math.ConstantToPlanarImage.MultiplyUnsignedShort.class })
public <S extends GenericShortType<S>> PlanarImg<S, ShortArray> multiply(
	final PlanarImg<S, ShortArray> arg, final short value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<S, ShortArray> result = (PlanarImg<S, ShortArray>) ops()
		.run(Ops.Math.Multiply.NAME, arg, value);
	return result;
}
 
Example #7
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToArrayImageP.SubtractShort.class,
	net.imagej.ops.math.ConstantToArrayImage.SubtractShort.class,
	net.imagej.ops.math.ConstantToArrayImageP.SubtractUnsignedShort.class,
	net.imagej.ops.math.ConstantToArrayImage.SubtractUnsignedShort.class })
public <S extends GenericShortType<S>> ArrayImg<S, ShortArray> subtract(
	final ArrayImg<S, ShortArray> image, final short value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<S, ShortArray> result = (ArrayImg<S, ShortArray>) ops().run(
		Ops.Math.Subtract.NAME, image, value);
	return result;
}
 
Example #8
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(ops = {
	net.imagej.ops.math.ConstantToPlanarImage.SubtractShort.class,
	net.imagej.ops.math.ConstantToPlanarImage.SubtractUnsignedShort.class })
public <S extends GenericShortType<S>> PlanarImg<S, ShortArray> subtract(
	final PlanarImg<S, ShortArray> image, final short value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<S, ShortArray> result = (PlanarImg<S, ShortArray>) ops()
		.run(Ops.Math.Subtract.NAME, image, value);
	return result;
}
 
Example #9
Source File: AbstractOpTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArrayImg<ShortType, ShortArray> generateShortArrayTestImg(
	final boolean fill, final long... dims)
{
	final short[] array = new short[(int) Intervals.numElements(
		new FinalInterval(dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (short) (pseudoRandom() / Integer.MAX_VALUE);
		}
	}

	return ArrayImgs.shorts(array, dims);
}
 
Example #10
Source File: AbstractOpTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArrayImg<UnsignedShortType, ShortArray>
	generateUnsignedShortArrayTestImg(final boolean fill, final long... dims)
{
	final short[] array = new short[(int) Intervals.numElements(
		new FinalInterval(dims))];

	if (fill) {
		seed = 17;
		for (int i = 0; i < array.length; i++) {
			array[i] = (short) (pseudoRandom() / Integer.MAX_VALUE);
		}
	}

	return ArrayImgs.unsignedShorts(array, dims);
}
 
Example #11
Source File: SCIFIOCellImgFactory.java    From scifio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
private <A extends ArrayDataAccess<A>> SCIFIOCellLoader<T, A>
	createCellLoader(final NativeTypeFactory<T, A> typeFactory)
{
	switch (typeFactory.getPrimitiveType()) {
		case BYTE:
			return new SCIFIOCellLoader(new ByteArrayLoader(reader, subregion),
				o -> new ByteArray((byte[]) o));
		case CHAR:
			return new SCIFIOCellLoader(new CharArrayLoader(reader, subregion),
				o -> new CharArray((char[]) o));
		case DOUBLE:
			return new SCIFIOCellLoader(new DoubleArrayLoader(reader, subregion),
				o -> new DoubleArray((double[]) o));
		case FLOAT:
			return new SCIFIOCellLoader(new FloatArrayLoader(reader, subregion),
				o -> new FloatArray((float[]) o));
		case INT:
			return new SCIFIOCellLoader(new IntArrayLoader(reader, subregion),
				o -> new IntArray((int[]) o));
		case LONG:
			return new SCIFIOCellLoader(new LongArrayLoader(reader, subregion),
				o -> new LongArray((long[]) o));
		case SHORT:
			return new SCIFIOCellLoader(new ShortArrayLoader(reader, subregion),
				o -> new ShortArray((short[]) o));
		default:
			throw new IllegalArgumentException();
	}
}
 
Example #12
Source File: LinearIntensityMap.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
public static void main( final String[] args )
{
	new ImageJ();

	final double[] coefficients = new double[]{
			0, 2, 4, 8,
			1, 1, 1, 1,
			1, 10, 5, 1,
			1, 1, 1, 1,

			0, 10, 20, 30,
			40, 50, 60, 70,
			80, 90, 100, 110,
			120, 130, 140, 150
	};

	final LinearIntensityMap< DoubleType > transform = new LinearIntensityMap< DoubleType >( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );

	//final ImagePlus imp = new ImagePlus( "http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png" );
	final ImagePlus imp1 = new ImagePlus( "http://fly.mpi-cbg.de/~saalfeld/Pictures/norway.jpg");

	final ArrayImg< FloatType, FloatArray > image1 = ArrayImgs.floats( ( float[] )imp1.getProcessor().convertToFloatProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< UnsignedByteType, ByteArray > image2 = ArrayImgs.unsignedBytes( ( byte[] )imp1.getProcessor().convertToByteProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< UnsignedShortType, ShortArray > image3 = ArrayImgs.unsignedShorts( ( short[] )imp1.getProcessor().convertToShortProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );
	final ArrayImg< ARGBType, IntArray > image4 = ArrayImgs.argbs( ( int[] )imp1.getProcessor().getPixels(), imp1.getWidth(), imp1.getHeight() );

	ImageJFunctions.show( ArrayImgs.doubles( coefficients, 4, 4, 2 ) );

	transform.run( image1 );
	transform.run( image2 );
	transform.run( image3 );
	transform.run( image4 );

	ImageJFunctions.show( image1 );
	ImageJFunctions.show( image2 );
	ImageJFunctions.show( image3 );
	ImageJFunctions.show( image4 );
}
 
Example #13
Source File: ShortArrayLoader.java    From scifio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public ShortArray emptyArray(final int entities) {
	return new ShortArray(entities);
}