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

The following examples show how to use net.imglib2.img.basictypeaccess.array.DoubleArray. 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: AffineWarpField.java    From render with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Logic stolen from
 * <a href='https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/org/janelia/intensity/LinearIntensityMap.java'>
 *   TrakEM2 LinearIntensityMap
 * </a>.
 *
 * @return an accessor for deriving warped pixel intensities.
 */
public RealRandomAccess<RealComposite<DoubleType>> getAccessor() {

    final ArrayImg<DoubleType, DoubleArray> warpField =
            ArrayImgs.doubles(values, columnCount, rowCount, VALUES_PER_AFFINE);

    final CompositeIntervalView<DoubleType, RealComposite<DoubleType>>
            collapsedSource = Views.collapseReal(warpField);

    final RandomAccessible<RealComposite<DoubleType>> extendedCollapsedSource = Views.extendBorder(collapsedSource);
    final RealRandomAccessible<RealComposite<DoubleType>> coefficients =
            Views.interpolate(extendedCollapsedSource, interpolatorFactory);

    final double xScale = getXScale();
    final double yScale = getYScale();
    final double[] scale = { xScale, yScale };
    final double[] shift = { 0.5 * xScale , 0.5 * yScale };

    final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation(scale, shift);

    final RealRandomAccessible<RealComposite<DoubleType>> stretchedCoefficients =
            RealViews.transform(coefficients, scaleAndTranslation);

    return stretchedCoefficients.realRandomAccess();
}
 
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.ConstantToArrayImageP.MultiplyDouble.class,
	net.imagej.ops.math.ConstantToArrayImage.MultiplyDouble.class })
public ArrayImg<DoubleType, DoubleArray> multiply(
	final ArrayImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<DoubleType, DoubleArray> result =
		(ArrayImg<DoubleType, DoubleArray>) ops().run(Ops.Math.Multiply.NAME,
			image, 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(op = net.imagej.ops.math.ConstantToPlanarImage.AddDouble.class)
public PlanarImg<DoubleType, DoubleArray> add(
	final PlanarImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<DoubleType, DoubleArray> result =
		(PlanarImg<DoubleType, DoubleArray>) ops().run(
			net.imagej.ops.Ops.Math.Add.class, 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.ConstantToArrayImageP.DivideDouble.class,
	net.imagej.ops.math.ConstantToArrayImage.DivideDouble.class })
public ArrayImg<DoubleType, DoubleArray> divide(
	final ArrayImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<DoubleType, DoubleArray> result =
		(ArrayImg<DoubleType, DoubleArray>) ops().run(Ops.Math.Divide.NAME, image,
			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(op = net.imagej.ops.math.ConstantToPlanarImage.DivideDouble.class)
public PlanarImg<DoubleType, DoubleArray> divide(
	final PlanarImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<DoubleType, DoubleArray> result =
		(PlanarImg<DoubleType, DoubleArray>) ops().run(
			net.imagej.ops.Ops.Math.Divide.class, 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.ConstantToArrayImageP.AddDouble.class,
	net.imagej.ops.math.ConstantToArrayImage.AddDouble.class })
public ArrayImg<DoubleType, DoubleArray> add(
	final ArrayImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<DoubleType, DoubleArray> result =
		(ArrayImg<DoubleType, DoubleArray>) ops().run(Ops.Math.Add.NAME, image,
			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(op = net.imagej.ops.math.ConstantToPlanarImage.MultiplyDouble.class)
public PlanarImg<DoubleType, DoubleArray> multiply(
	final PlanarImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<DoubleType, DoubleArray> result =
		(PlanarImg<DoubleType, DoubleArray>) ops().run(
			net.imagej.ops.Ops.Math.Multiply.class, 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.ConstantToArrayImageP.SubtractDouble.class,
	net.imagej.ops.math.ConstantToArrayImage.SubtractDouble.class })
public ArrayImg<DoubleType, DoubleArray> subtract(
	final ArrayImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final ArrayImg<DoubleType, DoubleArray> result =
		(ArrayImg<DoubleType, DoubleArray>) ops().run(Ops.Math.Subtract.NAME,
			image, value);
	return result;
}
 
Example #9
Source File: MathNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.math.ConstantToPlanarImage.SubtractDouble.class)
public PlanarImg<DoubleType, DoubleArray> subtract(
	final PlanarImg<DoubleType, DoubleArray> image, final double value)
{
	@SuppressWarnings("unchecked")
	final PlanarImg<DoubleType, DoubleArray> result =
		(PlanarImg<DoubleType, DoubleArray>) ops().run(
			net.imagej.ops.Ops.Math.Subtract.class, image, value);
	return result;
}
 
Example #10
Source File: AbstractOpTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public ArrayImg<DoubleType, DoubleArray> generateDoubleArrayTestImg(
	final boolean fill, final long... dims)
{
	final double[] array = new double[(int) Intervals.numElements(
		new FinalInterval(dims))];

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

	return ArrayImgs.doubles(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: DoubleArrayLoader.java    From scifio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
@Override
public DoubleArray emptyArray(final int entities) {
	return new DoubleArray(entities);
}