net.imglib2.type.numeric.IntegerType Java Examples

The following examples show how to use net.imglib2.type.numeric.IntegerType. 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: HighlightingStreamConverter.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings("unchecked")
public static <T> HighlightingStreamConverter<T> forType(
		final AbstractHighlightingARGBStream stream,
		final T t)
{
	LOG.debug("Getting {} for type {}", HighlightingStreamConverter.class.getSimpleName(), t);
	if (t instanceof VolatileLabelMultisetType) {
		return (HighlightingStreamConverter<T>) new HighlightingStreamConverterLabelMultisetType(stream);
	}
	if (t instanceof Volatile<?> && ((Volatile<?>)t).get() instanceof IntegerType<?>) {
		return (HighlightingStreamConverter<T>) new HighlightingStreamConverterIntegerType(stream);
	}

	return null;

}
 
Example #2
Source File: LabelSourceState.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static <D extends IntegerType<D> & NativeType<D>, T extends Volatile<D> & IntegerType<T>>
LabelSourceState<D, T> simpleSourceFromSingleRAI(
		final RandomAccessibleInterval<D> data,
		final double[] resolution,
		final double[] offset,
		final long maxId,
		final String name,
		final Group meshesGroup,
		final ObjectProperty<ViewFrustum> viewFrustumProperty,
		final ObjectProperty<AffineTransform3D> eyeToWorldTransformProperty,
		final ExecutorService meshManagerExecutors,
		final HashPriorityQueueBasedTaskExecutor<MeshWorkerPriority> meshWorkersExecutors) {

	return simpleSourceFromSingleRAI(
			data,
			resolution,
			offset,
			new NoOpInvalidate<>(),
			maxId,
			name,
			meshesGroup,
			viewFrustumProperty,
			eyeToWorldTransformProperty,
			meshManagerExecutors,
			meshWorkersExecutors);
}
 
Example #3
Source File: N5OpenSourceDialog.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <D extends NativeType<D> & IntegerType<D>, T extends Volatile<D> & NativeType<T>> void addLabel(
		final String name,
		final GenericBackendDialogN5 dataset,
		final PainteraBaseView viewer,
		final Supplier<String> projectDirectory) throws Exception {
	final DatasetAttributes attributes = dataset.getAttributes();
	if (attributes.getNumDimensions() > 3)
		throw new Exception("Only 3D label data supported but got " + attributes.getNumDimensions() + " dimensions.");

	final SourceState<D, T> rep = dataset.getLabels(
			name,
			viewer.getQueue(),
			viewer.getQueue().getNumPriorities() - 1,
			viewer.viewer3D().meshesGroup(),
			viewer.viewer3D().viewFrustumProperty(),
			viewer.viewer3D().eyeToWorldTransformProperty(),
			viewer.getMeshManagerExecutorService(),
			viewer.getMeshWorkerExecutorService(),
			viewer.getPropagationQueue(),
			projectDirectory
	);
	InvokeOnJavaFXApplicationThread.invoke(() -> viewer.addState(rep));
}
 
Example #4
Source File: Masks.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static <I extends IntegerType<I> & NativeType<I>, V extends AbstractVolatileRealType<I, V>> MaskedSource<I,
		V> fromIntegerType(
		final DataSource<I, V> source,
		final SharedQueue queue,
		final String initialCanvasPath,
		final PersistCanvas mergeCanvasIntoBackground,
		final ExecutorService propagationExecutor)
{
	return fromIntegerType(
			source,
			queue,
			initialCanvasPath,
			new TmpDirectoryCreator(null, null),
			mergeCanvasIntoBackground,
			propagationExecutor);
}
 
Example #5
Source File: FloodFillTransformedPlane.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static void fill(
		final AffineTransform3D localToWorld,
		final double[] min,
		final double[] max,
		final double zRangePos,
		final double zRangeNeg,
		final RandomAccess<? extends BooleanType<?>> relevantBackgroundAccess,
		final RandomAccess<? extends IntegerType<?>> localAccess,
		final RealLocalizable seedWorld,
		final long fillLabel)
{
	new FloodFillTransformedPlane(localToWorld, min[0], min[1], max[0], max[1], zRangePos, zRangeNeg).fill(
			relevantBackgroundAccess,
			localAccess,
			seedWorld,
			fillLabel
	                                                                                                      );
}
 
Example #6
Source File: FloodFill.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <T extends IntegerType<T>> void fillPrimitiveType(
		final RandomAccessibleInterval<T> input,
		final RandomAccessible<UnsignedLongType> output,
		final Localizable seed,
		final long seedLabel,
		final FragmentSegmentAssignment assignment)
{
	final T extension = Util.getTypeFromInterval(input).createVariable();
	extension.setInteger(Label.OUTSIDE);

	net.imglib2.algorithm.fill.FloodFill.fill(
			Views.extendValue(input, extension),
			output,
			seed,
			new UnsignedLongType(1),
			new DiamondShape(1),
			makePredicate(seedLabel, assignment)
		);
}
 
Example #7
Source File: CommitCanvasN5.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <I extends IntegerType<I> & NativeType<I>> void writeBlocksLabelIntegerType(
		final RandomAccessibleInterval<UnsignedLongType> canvas,
		final long[] blocks,
		final DatasetSpec datasetSpec,
		final BlockSpec blockSpec,
		final TLongObjectHashMap<BlockDiff> blockDiff) throws IOException {
	final RandomAccessibleInterval<I> highestResolutionData = N5Utils.open(datasetSpec.container, datasetSpec.dataset);
	final I i = Util.getTypeFromInterval(highestResolutionData).createVariable();
	for (final long blockId : blocks) {
		blockSpec.fromLinearIndex(blockId);
		final RandomAccessibleInterval<Pair<I, UnsignedLongType>> backgroundWithCanvas = Views.interval(Views.pair(highestResolutionData, canvas), blockSpec.asInterval());
		final RandomAccessibleInterval<I> mergedData = Converters.convert(backgroundWithCanvas, (s, t) -> pickFirstIfSecondIsInvalid(s.getA(), s.getB(), t), i.createVariable());
		N5Utils.saveBlock(mergedData, datasetSpec.container, datasetSpec.dataset, datasetSpec.attributes, blockSpec.pos);
		blockDiff.put(blockId, createBlockDiffFromCanvasIntegerType(Views.iterable(backgroundWithCanvas)));
	}
}
 
Example #8
Source File: PainteraBaseView.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 * convenience method to add a single {@link RandomAccessibleInterval} as single scale level {@link LabelSourceState}
 *
 * @param data input data
 * @param resolution voxel size
 * @param offset offset in global coordinates
 * @param maxId the maximum value in {@code data}
 * @param name name for source
 * @param <D> Data type of {@code state}
 * @param <T> Viewer type of {@code state}
 * @return the {@link LabelSourceState} that was built from the inputs and added to the viewer
 */
public <D extends IntegerType<D> & NativeType<D>, T extends Volatile<D> & IntegerType<T>> LabelSourceState<D, T>
addSingleScaleLabelSource(
		final RandomAccessibleInterval<D> data,
		final double[] resolution,
		final double[] offset,
		final long maxId,
		final String name) {
	final LabelSourceState<D, T> state = LabelSourceState.simpleSourceFromSingleRAI(
			data,
			resolution,
			offset,
			maxId,
			name,
			viewer3D().meshesGroup(),
			viewer3D().viewFrustumProperty(),
			viewer3D().eyeToWorldTransformProperty(),
			meshManagerExecutorService,
			meshWorkerExecutorService);
	InvokeOnJavaFXApplicationThread.invoke(() -> addState(state));
	return state;
}
 
Example #9
Source File: FloodFillTransformedCylinder3D.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static void fill(
		final AffineTransform3D localToWorld,
		final double radiusX,
		final double radiusY,
		final double zRangePos,
		final double zRangeNeg,
		final RandomAccess<? extends IntegerType<?>> localAccess,
		final RealLocalizable seedWorld,
		final long fillLabel)
{
	new FloodFillTransformedCylinder3D(localToWorld, radiusX, radiusY, zRangePos, zRangeNeg).fill(
			localAccess,
			seedWorld,
			fillLabel
	                                                                                             );
}
 
Example #10
Source File: IdSelector.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void accept(final MouseEvent e)
{
		final AffineTransform3D affine      = new AffineTransform3D();
		final ViewerState       viewerState = viewer.getState().copy();
		viewerState.getViewerTransform(affine);
		final AffineTransform3D screenScaleTransform = new AffineTransform3D();
		viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform);
		final int level = viewerState.getBestMipMapLevel(screenScaleTransform, source);

		source.getSourceTransform(0, level, affine);
		final RealRandomAccess<? extends IntegerType<?>> access =
				RealViews.transformReal(source.getInterpolatedDataSource(0, level, Interpolation.NEARESTNEIGHBOR), affine).realRandomAccess();
		viewer.getMouseCoordinates(access);
		access.setPosition(0L, 2);
		viewer.displayToGlobalCoordinates(access);
		final IntegerType<?> val = access.get();
		final long id  = val.getIntegerLong();
		actOn(id);
}
 
Example #11
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.imgLabeling.CreateImgLabelingFromInterval.class)
public <L, T extends IntegerType<T>> ImgLabeling<L, T> imgLabeling(
	final Interval interval, final T outType, final ImgFactory<T> fac,
	final int maxNumLabelSets)
{
	@SuppressWarnings("unchecked")
	final ImgLabeling<L, T> result =
		(ImgLabeling<L, T>) ops().run(
			Ops.Create.ImgLabeling.class,
			interval, outType, fac, maxNumLabelSets);
	return result;
}
 
Example #12
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToInt16.class)
public <T extends IntegerType<T>> ShortType int16(final ShortType out,
	final T in)
{
	final ShortType result = (ShortType) ops().run(
		Ops.Convert.Int16.class, out, in);
	return result;
}
 
Example #13
Source File: N5FragmentSegmentAssignmentInitialLut.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static <T extends IntegerType<T> & NativeType<T>> RandomAccessibleInterval<UnsignedLongType> openAnyIntegerTypeAsUnsignedLongType(
		final N5Reader reader,
		final String dataset
) throws IOException {
	final RandomAccessibleInterval<T> img = N5Utils.open(reader, dataset);
	return Converters.convert(img, (s, t) -> t.setInteger(s.getIntegerLong()), new UnsignedLongType());
}
 
Example #14
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToInt32.class)
public <T extends IntegerType<T>> IntType int32(final IntType out,
	final T in)
{
	final IntType result = (IntType) ops().run(
		Ops.Convert.Int32.class, out, in);
	return result;
}
 
Example #15
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToUint12.class)
public <T extends IntegerType<T>> Unsigned12BitType uint12(
	final Unsigned12BitType out, final T in)
{
	final Unsigned12BitType result = (Unsigned12BitType) ops().run(
		Ops.Convert.Uint12.class, out, in);
	return result;
}
 
Example #16
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToInt8.class)
public <T extends IntegerType<T>> ByteType int8(final ByteType out,
	final T in)
{
	final ByteType result = (ByteType) ops().run(
		Ops.Convert.Int8.class, out, in);
	return result;
}
 
Example #17
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToUint8.class)
public <T extends IntegerType<T>> UnsignedByteType uint8(
	final UnsignedByteType out, final T in)
{
	final UnsignedByteType result = (UnsignedByteType) ops().run(
		Ops.Convert.Uint8.class, out, in);
	return result;
}
 
Example #18
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.imgLabeling.DefaultCreateImgLabeling.class)
public <L, T extends IntegerType<T>> ImgLabeling<L, T> imgLabeling(
	final Dimensions dims, final T outType)
{
	@SuppressWarnings("unchecked")
	final ImgLabeling<L, T> result =
		(ImgLabeling<L, T>) ops().run(
			Ops.Create.ImgLabeling.class, dims,
			outType);
	return result;
}
 
Example #19
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToUint4.class)
public <T extends IntegerType<T>> Unsigned4BitType uint4(
	final Unsigned4BitType out, final T in)
{
	final Unsigned4BitType result = (Unsigned4BitType) ops().run(
		Ops.Convert.Uint4.class, out, in);
	return result;
}
 
Example #20
Source File: PainteraCommandLineArgs.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static long findMaxId(final RandomAccessibleInterval<? extends IntegerType<?>> rai) {
	long maxId = org.janelia.saalfeldlab.labels.Label.getINVALID();
	for (final IntegerType<?> t : Views.iterable(rai)) {
		final long id = t.getIntegerLong();
		if (id > maxId)
			maxId = id;
	}
	return maxId;
}
 
Example #21
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.imgLabeling.CreateImgLabelingFromInterval.class)
public <L, T extends IntegerType<T>> ImgLabeling<L, T> imgLabeling(
	final Interval interval)
{
	@SuppressWarnings("unchecked")
	final ImgLabeling<L, T> result =
		(ImgLabeling<L, T>) ops().run(
			Ops.Create.ImgLabeling.class,
			interval);
	return result;
}
 
Example #22
Source File: PainteraCommandLineArgs.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static IdService findMaxIdForIdServiceAndWriteToN5(
		final N5Writer n5,
		final String dataset,
		final DataSource<? extends IntegerType<?>, ?> source) throws IOException {
	final long maxId = Math.max(findMaxId(source), 0);
	n5.setAttribute(dataset, N5Helpers.MAX_ID_KEY, maxId);
	return new N5IdService(n5, dataset, maxId + 1);
}
 
Example #23
Source File: PainteraAlerts.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
private static long findMaxId(final RandomAccessibleInterval<? extends IntegerType<?>> rai) {
	long maxId = org.janelia.saalfeldlab.labels.Label.getINVALID();
	for (final IntegerType<?> t : Views.iterable(rai)) {
		final long id = t.getIntegerLong();
		if (id > maxId)
			maxId = id;
	}
	return maxId;
}
 
Example #24
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.imgLabeling.DefaultCreateImgLabeling.class)
public <L, T extends IntegerType<T>> ImgLabeling<L, T> imgLabeling(
	final Dimensions dims, final T outType, final ImgFactory<T> fac,
	final int maxNumLabelSets)
{
	@SuppressWarnings("unchecked")
	final ImgLabeling<L, T> result =
		(ImgLabeling<L, T>) ops().run(
			Ops.Create.ImgLabeling.class, dims,
			outType, fac, maxNumLabelSets);
	return result;
}
 
Example #25
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.integerType.DefaultCreateIntegerType.class)
public IntegerType integerType(final long maxValue) {
	final IntegerType result =
		(IntegerType) ops().run(
			Ops.Create.IntegerType.class,
			maxValue);
	return result;
}
 
Example #26
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	op = net.imagej.ops.create.imgLabeling.CreateImgLabelingFromInterval.class)
public <L, T extends IntegerType<T>> ImgLabeling<L, T> imgLabeling(
	final Interval interval, final T outType, final ImgFactory<T> fac)
{
	@SuppressWarnings("unchecked")
	final ImgLabeling<L, T> result =
		(ImgLabeling<L, T>) ops().run(
			Ops.Create.ImgLabeling.class,
			interval, outType, fac);
	return result;
}
 
Example #27
Source File: BackendDialog.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public <D extends NativeType<D> & IntegerType<D>, T extends Volatile<D> & NativeType<T>> LabelSourceState<D, T>
getLabels(
		final String name,
		final SharedQueue queue,
		final int priority,
		final Group meshesGroup,
		final ExecutorService manager,
		final ExecutorService workers,
		final String projectDirectory) throws Exception;
 
Example #28
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToInt64.class)
public <T extends IntegerType<T>> LongType int64(final LongType out,
	final T in)
{
	final LongType result = (LongType) ops().run(
		Ops.Convert.Int64.class, out, in);
	return result;
}
 
Example #29
Source File: ConvertNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(op = net.imagej.ops.convert.ConvertTypes.IntegerToUint32.class)
public <T extends IntegerType<T>> UnsignedIntType uint32(
	final UnsignedIntType out, final T in)
{
	final UnsignedIntType result = (UnsignedIntType) ops().run(
		Ops.Convert.Uint32.class, out, in);
	return result;
}
 
Example #30
Source File: InvertTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private <T extends IntegerType<T>> void
	assertIntegerInvertMinMaxProvided(final Img<T> in, final Img<T> out,
		final T min, final T max)
{

	// unsigned type test
	final Op op = ops.op(Ops.Image.Invert.class, out, in, min, max);
	assertSame(InvertIIInteger.class, op.getClass());
	op.run();

	integerCompare(in, out, min, max);

}