net.imglib2.IterableInterval Java Examples

The following examples show how to use net.imglib2.IterableInterval. 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: DefaultSumVariance.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final IterableInterval<T> input,
	final DoubleType output)
{
	final double[][] matrix = getCooccurrenceMatrix(input);

	final double[] pxplusy = coocPXPlusYFunc.calculate(matrix);
	final int nrGrayLevels = matrix.length;
	final double sumEntropy = sumEntropyFunc.calculate(input).getRealDouble();

	double res = 0;
	for (int i = 2; i <= 2 * nrGrayLevels; i++) {
		res += (i - sumEntropy) * (i - sumEntropy) * pxplusy[i];
	}

	output.set(res);
}
 
Example #2
Source File: DefaultMaxProbability.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final IterableInterval<T> input, final DoubleType output) {
	final double[][] matrix = getCooccurrenceMatrix(input);

	final double nrGreyLevel = matrix.length;

	double res = 0;
	for (int i = 0; i < nrGreyLevel; i++) {
		for (int j = 0; j < nrGreyLevel; j++) {
			if (matrix[i][j] > res)
				res = matrix[i][j];
		}
	}

	output.set(res);
}
 
Example #3
Source File: IntegralAdd.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final IterableInterval<I> input,
	final IterableInterval<I> output)
{

	final Cursor<I> inputCursor = input.cursor();
	final Cursor<I> outputCursor = output.cursor();

	double tmp = 0.0d;
	while (outputCursor.hasNext()) {

		final I inputValue = inputCursor.next();
		final I outputValue = outputCursor.next();

		tmp += inputValue.getRealDouble();

		outputValue.setReal(tmp);
	}
}
 
Example #4
Source File: DefaultErode.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final RandomAccessibleInterval<T> in1, final Shape in2,
	final IterableInterval<T> output)
{
	final RandomAccessibleInterval<T> shifted;
	if (isFull) {
		final long[] offset = MorphologyUtils
			.computeTargetImageDimensionsAndOffset(in1, in2)[1];
		shifted = Views.translate(in1, offset);
	}
	else {
		shifted = in1;
	}
	final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extended =
		Views.extend(shifted, f);
	Erosion.erode(extended, output, in2, maxVal, Runtime.getRuntime()
		.availableProcessors());
}
 
Example #5
Source File: DefaultCenterOfGravity.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public RealLocalizable calculate(final IterableInterval<T> input) {
	final int numDimensions = input.numDimensions();

	final double[] output = new double[numDimensions];
	final double[] intensityValues = new double[numDimensions];

	final Cursor<T> c = input.localizingCursor();
	while (c.hasNext()) {
		c.fwd();
		for (int i = 0; i < output.length; i++) {
			output[i] += c.getDoublePosition(i) * c.get().getRealDouble();
			intensityValues[i] += c.get().getRealDouble();
		}
	}

	for (int i = 0; i < output.length; i++) {
		output[i] = output[i] / intensityValues[i];
	}

	return new RealPoint(output);
}
 
Example #6
Source File: DefaultCoordinatesEquation.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final UnaryFunctionOp<long[], N> op,
	final IterableInterval<T> output)
{

	final Cursor<T> c = output.localizingCursor();
	final long[] pos = new long[output.numDimensions()];

	// loop through all pixels, set the current position and call the op
	while (c.hasNext()) {
		c.fwd();
		c.localize(pos);

		for (int i = 0; i < output.numDimensions(); i++) {

			op.calculate(pos);

			c.get().setReal(op.calculate(pos).floatValue());

		}

	}
}
 
Example #7
Source File: BrightestViewSelection.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public <T extends RealType<T>> T getMean(IterableInterval< T > img)
{
	RealSum sum = new RealSum();
	long nPix = 0;
	
	for (T t : img)
	{
		sum.add( t.getRealDouble() );
		nPix++;
	}
	
	T res = img.firstElement().createVariable();
	res.setReal( sum.getSum()/nPix );
	return res;
	
}
 
Example #8
Source File: CostesSignificanceTest.java    From Colocalisation_Analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Goes stepwise through the y-dimensions of the image data and adds cursors
 * for each row to the given list. The method does not check if there is a
 * y-dimensions, so this should be made sure before. you can enforce to
 * create all cursors as out-of-bounds one.
 *
 * @param img The image to get the data and cursors from.
 * @param blockList The list to put the blocks into.
 * @param offset The current offset configuration. Only [0] and [1] will be changed.
 * @param size
 */
protected void generateBlocksXY(RandomAccessible<T> img, List<IterableInterval<T>> blockList,
		double[] offset, double[] size) {
	// potentially masked image height
	double height = size[1];
	final double originalY = offset[1];
	// go through the height in steps of block width
	double y;
	for ( y = psfRadius[1]; y <= height; y += psfRadius[1] ) {
		offset[1] = originalY + y - psfRadius[1];
		generateBlocksX(img, blockList, offset, size);
	}
	// check is we need to add a out of bounds strategy cursor
	if (y > height) {
		offset[1] = originalY + y - psfRadius[1];
		generateBlocksX(img, blockList, offset, size);
	}
	offset[1] = originalY;
}
 
Example #9
Source File: ProjectRAIToIterableInterval.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void compute(final RandomAccessibleInterval<T> input,
	final IterableInterval<V> output)
{
	final Cursor<V> cursor = output.localizingCursor();
	final RandomAccess<T> access = input.randomAccess();

	while (cursor.hasNext()) {
		cursor.fwd();
		for (int d = 0; d < input.numDimensions(); d++) {
			if (d != dim) {
				access.setPosition(cursor.getIntPosition(d - (d > dim ? -1 : 0)), d);
			}
		}

		method.compute(new DimensionIterable(input.dimension(dim), access),
			cursor.get());
	}
}
 
Example #10
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.imagemoments.hu.DefaultHuMoment3.class)
public <I extends RealType<I>, O extends RealType<O>> O huMoment3(
	final IterableInterval<I> in)
{
	final O result =
		(O) ops().run(net.imagej.ops.Ops.ImageMoments.HuMoment3.class, in);
	return result;
}
 
Example #11
Source File: FilterNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Executes the "tubeness" filter operation on the given arguments. */
@OpMethod(op = net.imagej.ops.filter.tubeness.DefaultTubeness.class)
public <T extends RealType<T>> IterableInterval<DoubleType> tubeness(
	final RandomAccessibleInterval<T> in, final double sigma,
	final double... calibration)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<DoubleType> result =
		(IterableInterval<DoubleType>) ops().run(Ops.Filter.Tubeness.class, in,
			sigma, calibration);
	return result;
}
 
Example #12
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.imagemoments.hu.DefaultHuMoment1.class)
public <I extends RealType<I>, O extends RealType<O>> O huMoment1(
	final IterableInterval<I> in)
{
	final O result =
		(O) ops().run(net.imagej.ops.Ops.ImageMoments.HuMoment1.class, in);
	return result;
}
 
Example #13
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.imagemoments.hu.DefaultHuMoment4.class)
public <I extends RealType<I>, O extends RealType<O>> O huMoment4(
	final IterableInterval<I> in)
{
	final O result =
		(O) ops().run(net.imagej.ops.Ops.ImageMoments.HuMoment4.class, in);
	return result;
}
 
Example #14
Source File: ThresholdNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalMaxLikelihoodThreshold.class)
public <T extends RealType<T>, B extends BooleanType<B>> IterableInterval<B>
	maxLikelihood(final IterableInterval<B> out,
		final RandomAccessibleInterval<T> in, final Shape shape)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<B> result = (IterableInterval<B>) ops().run(
		net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalMaxLikelihoodThreshold.class,
		out, in, shape);
	return result;
}
 
Example #15
Source File: DefaultNormalizedCentralMoment20.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void compute(final IterableInterval<I> input, final O output) {
	double centralMoment00 = centralMoment00Func.calculate(input).getRealDouble();
	double centralMoment20 = centralMoment20Func.calculate(input).getRealDouble();

	output.setReal(centralMoment20 /
		Math.pow(centralMoment00, 1 + ((2 + 0) / 2.0)));
}
 
Example #16
Source File: HaralickNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.features.haralick.DefaultClusterShade.class)
public <T extends RealType<T>> DoubleType clusterShade(final DoubleType out,
	final IterableInterval<T> in, final int numGreyLevels, final int distance,
	final MatrixOrientation orientation)
{
	final DoubleType result = (DoubleType) ops().run(
		net.imagej.ops.Ops.Haralick.ClusterShade.class, out, in,
		numGreyLevels, distance, orientation);
	return result;
}
 
Example #17
Source File: HaralickNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.features.haralick.DefaultSumEntropy.class)
public <T extends RealType<T>> DoubleType sumEntropy(
	final IterableInterval<T> in, final int numGreyLevels, final int distance,
	final MatrixOrientation orientation)
{
	final DoubleType result = (DoubleType) ops().run(
		net.imagej.ops.Ops.Haralick.SumEntropy.class, in,
		numGreyLevels, distance, orientation);
	return result;
}
 
Example #18
Source File: ImageNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Executes the "equation" operation on the given arguments. */
@OpMethod(op = net.imagej.ops.image.equation.DefaultEquation.class)
public <T extends RealType<T>> IterableInterval<T> equation(final String in) {
	@SuppressWarnings("unchecked")
	final IterableInterval<T> result = (IterableInterval<T>) ops().run(
		net.imagej.ops.Ops.Image.Equation.class, in);
	return result;
}
 
Example #19
Source File: DefaultErode.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public IterableInterval<T> createOutput(final RandomAccessibleInterval<T> in1,
	final Shape in2)
{
	if (isFull) {
		final long[] dims = MorphologyUtils.computeTargetImageDimensionsAndOffset(
			in1, in2)[0];
		return imgCreator.calculate(new FinalInterval(dims));
	}
	return imgCreator.calculate(in1);
}
 
Example #20
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.imagemoments.centralmoments.DefaultCentralMoment02.class)
public
	<I extends RealType<I>, O extends RealType<O>> O centralMoment02(
		final IterableInterval<I> in)
{
	final O result =
		(O) ops()
			.run(
				net.imagej.ops.Ops.ImageMoments.CentralMoment02.class,
				in);
	return result;
}
 
Example #21
Source File: ThresholdNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalHuangThreshold.class)
public <T extends RealType<T>, B extends BooleanType<B>> IterableInterval<B>
	huang(final IterableInterval<B> out, final RandomAccessibleInterval<T> in,
		final Shape shape)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<B> result = (IterableInterval<B>) ops().run(
		net.imagej.ops.threshold.ApplyThresholdMethodLocal.LocalHuangThreshold.class,
		out, in, shape);
	return result;
}
 
Example #22
Source File: ThresholdNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.threshold.ApplyThresholdMethod.Percentile.class)
public
	<T extends RealType<T>> IterableInterval<BitType> percentile(final IterableInterval<T> in) {
	@SuppressWarnings("unchecked")
	final IterableInterval<BitType> result =
		(IterableInterval<BitType>) ops().run(
			net.imagej.ops.Ops.Threshold.Percentile.class,
			in);
	return result;
}
 
Example #23
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.imagemoments.normalizedcentralmoments.DefaultNormalizedCentralMoment30.class)
public
	<I extends RealType<I>, O extends RealType<O>> O normalizedCentralMoment30(
		final IterableInterval<I> in)
{
	final O result =
		(O) ops()
			.run(
				net.imagej.ops.Ops.ImageMoments.NormalizedCentralMoment30.class,
				in);
	return result;
}
 
Example #24
Source File: ThresholdNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.threshold.localMidGrey.LocalMidGreyThreshold.class)
public <T extends RealType<T>> IterableInterval<BitType> localMidGreyThreshold(
	final IterableInterval<BitType> out, final RandomAccessibleInterval<T> in,
	final Shape shape,
	final OutOfBoundsFactory<T, RandomAccessibleInterval<T>> outOfBounds,
	final double c)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<BitType> result = (IterableInterval<BitType>) ops()
		.run(net.imagej.ops.Ops.Threshold.LocalMidGreyThreshold.class, out,
			in, shape, outOfBounds, c);
	return result;
}
 
Example #25
Source File: ImageNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/** Executes the "equation" operation on the given arguments. */
@OpMethod(op = net.imagej.ops.image.equation.DefaultXYEquation.class)
public <T extends RealType<T>> IterableInterval<T> equation(
	final IterableInterval<T> out, final DoubleBinaryOperator in)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<T> result = (IterableInterval<T>) ops().run(
		net.imagej.ops.Ops.Image.Equation.class, out, in);
	return result;
}
 
Example #26
Source File: ListClose.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void compute(final RandomAccessibleInterval<T> in1,
	final List<Shape> in2, final IterableInterval<T> out)
{
	final Img<T> buffer = imgCreator.calculate(out);
	dilateComputer.compute(in1, in2, buffer);
	erodeComputer.compute(Views.interval(Views.extendValue(buffer, maxVal),
		out), in2, out);
}
 
Example #27
Source File: MorphologyNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.morphology.erode.ListErode.class)
public <T extends RealType<T>> IterableInterval<T> erode(
	final IterableInterval<T> out, final RandomAccessibleInterval<T> in1,
	final List<Shape> in2, final boolean isFull)
{
	@SuppressWarnings("unchecked")
	final IterableInterval<T> result = (IterableInterval<T>) ops().run(
		net.imagej.ops.Ops.Morphology.Erode.class, out, in1, in2, isFull);
	return result;
}
 
Example #28
Source File: ThresholdNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.threshold.ApplyThresholdMethod.Moments.class)
public <T extends RealType<T>> IterableInterval<BitType> moments(final IterableInterval<T> in) {
	@SuppressWarnings("unchecked")
	final IterableInterval<BitType> result =
		(IterableInterval<BitType>) ops()
			.run(
				net.imagej.ops.Ops.Threshold.Moments.class,
				in);
	return result;
}
 
Example #29
Source File: Maps.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <O> void map(final IterableInterval<O> a,
	final NullaryComputerOp<O> op, final long startIndex, final long stepSize,
	final long numSteps)
{
	if (numSteps <= 0) return;
	final Cursor<O> aCursor = a.cursor();

	for (long ctr = 0; ctr < numSteps; ctr++) {
		aCursor.jumpFwd(ctr == 0 ? startIndex + 1 : stepSize);
		op.compute(aCursor.get());
	}
}
 
Example #30
Source File: ImageMomentsNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.imagemoments.normalizedcentralmoments.DefaultNormalizedCentralMoment20.class)
public
	<I extends RealType<I>, O extends RealType<O>> O normalizedCentralMoment20(
		final O out, final IterableInterval<I> in)
{
	final O result =
		(O) ops()
			.run(
				net.imagej.ops.Ops.ImageMoments.NormalizedCentralMoment20.class,
				out, in);
	return result;
}