net.imglib2.type.NativeType Java Examples

The following examples show how to use net.imglib2.type.NativeType. 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: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param priority in fetching queue
 * @param <T> data type
 * @param <V> viewer type
 * @return image data and cache invalidation
 * @throws IOException if any N5 operation throws {@link IOException}
 */
@SuppressWarnings("unused")
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
ImagesWithTransform<T, V> openRaw(
		final N5Reader reader,
		final String dataset,
		final SharedQueue queue,
		final int priority) throws IOException
{
	return openRaw(
			reader,
			dataset,
			N5Helpers.getResolution(reader, dataset),
			N5Helpers.getOffset(reader, dataset),
			queue,
			priority);
}
 
Example #2
Source File: ColocalisationTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * This method creates a noise image that has a specified mean. Every pixel
 * has a value uniformly distributed around mean with the maximum spread
 * specified.
 *
 * @return IllegalArgumentException if specified means and spreads are not
 *         valid
 */
public static <T extends RealType<T> & NativeType<T>>
	Img<T> produceMeanBasedNoiseImage(T type, int width,
		int height, double mean, double spread, double[] smoothingSigma,
		long seed) throws IllegalArgumentException
{
	if (mean < spread || (mean + spread) > type.getMaxValue()) {
		throw new IllegalArgumentException(
			"Mean must be larger than spread, and mean plus spread must be smaller than max of the type");
	}
	// create the new image
	ImgFactory<T> imgFactory = new ArrayImgFactory<>(type);
	Img<T> noiseImage = imgFactory.create(width, height);

	Random r = new Random(seed);
	for (T value : Views.iterable(noiseImage)) {
		value.setReal(mean + ((r.nextDouble() - 0.5) * spread));
	}

	// TODO: call Ops filter.gauss instead
	return gaussianSmooth(noiseImage, smoothingSigma);
}
 
Example #3
Source File: SlideBook6.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected ImgFactory<? extends NativeType<?>> selectImgFactory(final SlideBook6MetaData meta) {
    int[] dims = meta.imageSize(0);
    long maxNumPixels = dims[0];
    maxNumPixels *= dims[1];
    maxNumPixels *= dims[2];

    String s = "Maximum number of pixels in any view: n=" + Long.toString(maxNumPixels) +
            " px ";

    if (maxNumPixels < Integer.MAX_VALUE) {
        IOFunctions.println(s + "< " + Integer.MAX_VALUE + ", using ArrayImg.");
        return new ArrayImgFactory<FloatType>();
    } else {
        IOFunctions.println(s + ">= " + Integer.MAX_VALUE + ", using CellImg.");
        return new CellImgFactory<FloatType>(256);
    }
}
 
Example #4
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
public static <
		D extends RealType<D> & NativeType<D>,
		T extends AbstractVolatileRealType<D, T> & NativeType<T>> N5ChannelDataSource<D, T> valueExtended(
		final N5Meta meta,
		final AffineTransform3D transform,
		final String name,
		final SharedQueue queue,
		final int priority,
		final int channelDimension,
		final long[] channels,
		final double extension) throws IOException, DataTypeNotSupported {

	return extended(
			meta, transform,
			name,
			queue,
			priority,
			channelDimension,
			channels,
			d -> d.setReal(extension),
			t -> t.setReal(extension)
	);
}
 
Example #5
Source File: ShapeInterpolationMode.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <R extends RealType<R> & NativeType<R>, B extends BooleanType<B>> void computeSignedDistanceTransform(
		final RandomAccessibleInterval<B> mask,
		final RandomAccessibleInterval<R> target,
		final DISTANCE_TYPE distanceType,
		final double... weights)
{
	final RandomAccessibleInterval<R> distanceOutside = target;
	final RandomAccessibleInterval<R> distanceInside = new ArrayImgFactory<>(Util.getTypeFromInterval(target)).create(target);
	DistanceTransform.binaryTransform(mask, distanceOutside, distanceType, weights);
	DistanceTransform.binaryTransform(Logical.complement(mask), distanceInside, distanceType, weights);
	LoopBuilder.setImages(distanceOutside, distanceInside, target).forEachPixel((outside, inside, result) -> {
		switch (distanceType)
		{
		case EUCLIDIAN:
			result.setReal(Math.sqrt(outside.getRealDouble()) - Math.sqrt(inside.getRealDouble()));
			break;
		case L1:
			result.setReal(outside.getRealDouble() - inside.getRealDouble());
			break;
		}
	});
}
 
Example #6
Source File: ExportSpimData2TIFF.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
@Override
public < T extends RealType< T > & NativeType< T > > boolean exportImage( final RandomAccessibleInterval<T> img, final BoundingBoxGUI bb, final TimePoint tp, final ViewSetup vs, final double min, final double max )
{
	// write the image
	if ( !this.saver.exportImage( img, bb, tp, vs, min, max ) )
		return false;

	// update the registrations
	final ViewRegistration vr = spimData.getViewRegistrations().getViewRegistration( new ViewId( tp.getId(), vs.getId() ) );
	
	final double scale = bb.getDownSampling();
	final AffineTransform3D m = new AffineTransform3D();
	m.set( scale, 0.0f, 0.0f, bb.min( 0 ), 
		   0.0f, scale, 0.0f, bb.min( 1 ),
		   0.0f, 0.0f, scale, bb.min( 2 ) );
	final ViewTransform vt = new ViewTransformAffine( "fusion bounding box", m );

	vr.getTransformList().clear();
	vr.getTransformList().add( vt );
	
	return true;
}
 
Example #7
Source File: N5ChannelDataSource.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
private static <D extends NativeType<D> & RealType<D>, T extends RealType<T>> RealComposite<T>  createExtension(
		final D d,
		final T t,
		final Converter<D, T> converter,
		final long size,
		IntFunction<D> valueAtIndex
)
{
	LOG.debug("Creating extension with size {}", size);
	final ArrayImg<D, ?> img = new ArrayImgFactory<>(d).create(1, size);
	img.setLinkedType((D) d.getNativeTypeFactory().createLinkedType((NativeImg)img));
	final CompositeIntervalView<D, RealComposite<D>> collapsed = Views.collapseReal(img);
	RealComposite<D> extensionCopy = collapsed.randomAccess().get();
	for (int channel = 0; channel < size; ++channel)
		extensionCopy.get(channel).set(valueAtIndex.apply(channel));
	return Views.collapseReal(Converters.convert((RandomAccessibleInterval<D>)img, converter, t.createVariable())).randomAccess().get();
}
 
Example #8
Source File: DeconvolveNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@OpMethod(op = net.imagej.ops.deconvolve.PadAndRichardsonLucy.class)
public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
	RandomAccessibleInterval<O> richardsonLucy(
		final RandomAccessibleInterval<O> out,
		final RandomAccessibleInterval<I> in,
		final RandomAccessibleInterval<K> kernel, final long[] borderSize,
		final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
		final OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel,
		final O outType, final C fftType, final int maxIterations)
{
	@SuppressWarnings("unchecked")
	final RandomAccessibleInterval<O> result =
		(RandomAccessibleInterval<O>) ops().run(
			net.imagej.ops.deconvolve.PadAndRichardsonLucy.class, out, in, kernel,
			borderSize, obfInput, obfKernel, outType, fftType, maxIterations);
	return result;
}
 
Example #9
Source File: Max_Project.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
public static < T extends RealType< T > & NativeType< T > > boolean maxProject(
		final SpimData data,
		final List< ? extends ViewId > viewIds,
		final T type )
{
	final ArrayList< ViewDescription > list = new ArrayList< ViewDescription >();

	for ( final ViewId viewId : viewIds )
	{
		final ViewDescription vd = data.getSequenceDescription().getViewDescription( viewId );

		if ( vd != null && vd.isPresent() )
			list.add( vd );
	}

	return maxProject( list, data.getSequenceDescription().getImgLoader(), type );
}
 
Example #10
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>> BlockDiff downsampleIntegerTypeAndSerialize(
		final N5Writer n5,
		final String dataset,
		final DatasetAttributes attributes,
		final RandomAccessibleInterval<I> data,
		final int[] relativeFactors,
		final int[] size,
		final Interval blockInterval,
		final long[] blockPosition
) throws IOException {
	final I i = Util.getTypeFromInterval(data).createVariable();
	i.setInteger(Label.OUTSIDE);
	final RandomAccessibleInterval<I> input = Views.isZeroMin(data) ? data : Views.zeroMin(data);
	final RandomAccessibleInterval<I> output = new ArrayImgFactory<>(i).create(size);
	WinnerTakesAll.downsample(input, output, relativeFactors);

	final RandomAccessibleInterval<I> previousContents = Views.offsetInterval(N5Utils.<I>open(n5, dataset), blockInterval);
	final BlockDiff blockDiff = createBlockDiffInteger(previousContents, output);

	N5Utils.saveBlock(output, n5, dataset, attributes, blockPosition);
	return blockDiff;
}
 
Example #11
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 #12
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 #13
Source File: TestImageAccessor.java    From Colocalisation_Analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method creates a noise image that has a specified mean.
 * Every pixel has a value uniformly distributed around mean with
 * the maximum spread specified.
 *
 * @return a new noise image
 * @throws MissingPreconditionException if specified means and spreads are not valid
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceMeanBasedNoiseImage(T type, int width,
		int height, double mean, double spread, double[] smoothingSigma, long seed) throws MissingPreconditionException {
	if (mean < spread || (mean + spread) > type.getMaxValue()) {
		throw new MissingPreconditionException("Mean must be larger than spread, and mean plus spread must be smaller than max of the type");
	}
	// create the new image
	ImgFactory<T> imgFactory = new ArrayImgFactory<T>();
	RandomAccessibleInterval<T> noiseImage = imgFactory.create( new int[] {width, height}, type); // "Noise image");

	Random r = new Random(seed);
	for (T value : Views.iterable(noiseImage)) {
		value.setReal( mean + ( (r.nextDouble() - 0.5) * spread ) );
	}

	return gaussianSmooth(noiseImage, smoothingSigma);
}
 
Example #14
Source File: ColocalisationTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
	 * Loads a Tiff file from within the jar to use as a mask Cursor.
	 * So we use Img<T> which has a cursor() method. 
	 * The given path is treated
	 * as relative to this tests-package (i.e. "Data/test.tiff" refers
	 * to the test.tiff in sub-folder Data).
	 *
	 * @param <T> The wanted output type.
	 * @param relPath The relative path to the Tiff file.
	 * @return The file as ImgLib image.
	 */
	private <T extends RealType<T> & NativeType<T>> Img<T> loadTiffFromJar(
		final String relPath)
	{
//		InputStream is = TestImageAccessor.class.getResourceAsStream(relPath);
//		BufferedInputStream bis = new BufferedInputStream(is);

		final ImgOpener opener = new ImgOpener(context);

		// HACK: Read data from file system for now.
		// Until this is fixed, the test will not pass when run from a JAR file.
		String source = "src/test/resources/net/imagej/ops/coloc/" + relPath;
		try {
			return (Img) opener.openImgs(source).get(0);
		}
		catch (final ImgIOException exc) {
			throw new IllegalStateException("File " + relPath +
				" is unexpectedly inaccessible?");
		}
	}
 
Example #15
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param resolution voxel resolution
 * @param offset offset in real world coordinates
 * @param priority in fetching queue
 * @param <T> data type
 * @param <V> viewer type
 * @return multi-scale image data with cache invalidation
 * @throws IOException if any N5 operation throws {@link IOException}
 */
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
ImagesWithTransform<T, V>[] openRawMultiscale(
		final N5Reader reader,
		final String dataset,
		final double[] resolution,
		final double[] offset,
		final SharedQueue queue,
		final int priority) throws IOException
{
	final AffineTransform3D transform = new AffineTransform3D();
	transform.set(
			resolution[0], 0, 0, offset[0],
			0, resolution[1], 0, offset[1],
			0, 0, resolution[2], offset[2]
	             );
	return openRawMultiscale(reader, dataset, transform, queue, priority);
}
 
Example #16
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param transform transforms voxel data into real world coordinates
 * @param priority in fetching queue
 * @param <T> data type
 * @param <V> viewer type
 * @return image data with cache invalidation
 * @throws IOException if any N5 operation throws {@link IOException}
 */
@SuppressWarnings("unchecked")
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>, A extends ArrayDataAccess<A>>
ImagesWithTransform<T, V> openRaw(
		final N5Reader reader,
		final String dataset,
		final AffineTransform3D transform,
		final SharedQueue queue,
		final int priority /* TODO use priority, probably in wrapAsVolatile? */) throws IOException {

	try {
		final CachedCellImg<T, ?> raw = N5Utils.openVolatile(reader, dataset);
		final TmpVolatileHelpers.RaiWithInvalidate<V> vraw = TmpVolatileHelpers.createVolatileCachedCellImgWithInvalidate(
				(CachedCellImg) raw,
				queue,
				new CacheHints(LoadingStrategy.VOLATILE, priority, true));
		return new ImagesWithTransform<>(raw, vraw.getRai(), transform, raw.getCache(), vraw.getInvalidate());
	}
	catch (final Exception e)
	{
		throw e instanceof IOException ? (IOException) e : new IOException(e);
	}
}
 
Example #17
Source File: TestImageAccessor.java    From Colocalisation_Analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Converts an arbitrary image to a black/white version of it.
 * All image data lower or equal the splitValue will get black,
 * the rest will turn white.
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> makeBinaryImage(
		RandomAccessibleInterval<T> image, T splitValue) {
	Cursor<T> imgCursor = Views.iterable(image).localizingCursor();
	// make a new image of the same type, but binary
	long[] dim = new long[ image.numDimensions() ];
	image.dimensions(dim);
	ArrayImgFactory<T> imgFactory = new ArrayImgFactory<T>();
	RandomAccessibleInterval<T> binImg = imgFactory.create( dim,
			image.randomAccess().get().createVariable() ); // "Binary image of " + image.getName());
	RandomAccess<T> invCursor = binImg.randomAccess();

	while (imgCursor.hasNext()) {
		imgCursor.fwd();
		invCursor.setPosition(imgCursor);
		T currentValue = invCursor.get();
		if (currentValue.compareTo(splitValue) > 0)
			currentValue.setReal(  currentValue.getMaxValue() );
		else
			currentValue.setZero();
	}

	return binImg;
}
 
Example #18
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 #19
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
ImagesWithTransform<T, V> openRaw(
		final N5Reader reader,
		final String dataset,
		final double[] resolution,
		final double[] offset,
		final SharedQueue queue,
		final int priority) throws IOException
{
	final AffineTransform3D transform = new AffineTransform3D();
	transform.set(
			resolution[0], 0, 0, offset[0],
			0, resolution[1], 0, offset[1],
			0, 0, resolution[2], offset[2]
	             );
	return openRaw(reader, dataset, transform, queue, priority);
}
 
Example #20
Source File: TestImageAccessor.java    From Colocalisation_Analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Inverts an image.
 *
 * @param <T> The images data type.
 * @param image The image to convert.
 * @return The inverted image.
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> invertImage(
		RandomAccessibleInterval<T> image) {
	Cursor<T> imgCursor = Views.iterable(image).localizingCursor();
	// invert the image
	long[] dim = new long[ image.numDimensions() ];
	image.dimensions(dim);
	ArrayImgFactory<T> imgFactory = new ArrayImgFactory<T>();
	RandomAccessibleInterval<T> invImg = imgFactory.create(
			dim, image.randomAccess().get().createVariable() ); // "Inverted " + image.getName());
	RandomAccess<T> invCursor = invImg.randomAccess();

	while (imgCursor.hasNext()) {
		imgCursor.fwd();
		invCursor.setPosition(imgCursor);
		invCursor.get().setReal( imgCursor.get().getMaxValue() - imgCursor.get().getRealDouble() );
	}

	return invImg;
}
 
Example #21
Source File: N5Data.java    From paintera with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param reader container
 * @param dataset dataset
 * @param transform transforms voxel data into real world coordinates
 * @param priority in fetching queue
 * @param dataInterpolation interpolator factory for data
 * @param interpolation interpolator factory for viewer data
 * @param name initialize with this name
 * @param <T> data type
 * @param <V> viewer type
 * @return {@link DataSource}
 * @throws IOException if any N5 operation throws {@link IOException}
 */
public static <T extends NativeType<T>, V extends Volatile<T> & NativeType<V>>
DataSource<T, V> openScalarAsSource(
		final N5Reader reader,
		final String dataset,
		final AffineTransform3D transform,
		final SharedQueue queue,
		final int priority,
		final Function<Interpolation, InterpolatorFactory<T, RandomAccessible<T>>> dataInterpolation,
		final Function<Interpolation, InterpolatorFactory<V, RandomAccessible<V>>> interpolation,
		final String name) throws IOException, ReflectionException {

	LOG.debug("Creating N5 Data source from {} {}", reader, dataset);
	return new N5DataSource<>(
			Objects.requireNonNull(N5Meta.fromReader(reader, dataset)),
			transform,
			name,
			queue,
			priority,
			dataInterpolation,
			interpolation);
}
 
Example #22
Source File: DeconvolveNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Deprecated
public <I extends RealType<I> & NativeType<I>, K extends RealType<K>, C extends ComplexType<C>>
	RandomAccessibleInterval<I> richardsonLucy(
		final RandomAccessibleInterval<I> in1,
		final RandomAccessibleInterval<K> in2,
		final RandomAccessibleInterval<C> fftInput,
		final RandomAccessibleInterval<C> fftKernel,
		final boolean performInputFFT, final int maxIterations)
{
	return richardsonLucy(create(in1), in1, in2, fftInput, fftKernel,
		performInputFFT, maxIterations);
}
 
Example #23
Source File: DeconvolveNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Deprecated
public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
	RandomAccessibleInterval<O> richardsonLucy(
		final RandomAccessibleInterval<I> in,
		final RandomAccessibleInterval<K> kernel, final long[] borderSize,
		final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
		final OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel,
		final O outType, final C fftType, final int maxIterations,
		final boolean nonCirculant)
{
	return richardsonLucy(create(in, outType), in, kernel, borderSize, obfInput,
		obfKernel, outType, fftType, maxIterations, nonCirculant);
}
 
Example #24
Source File: CreateOutputFFTMethods.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void initialize() {
	super.initialize();

	create = (BinaryFunctionOp) Functions.unary(ops(), Ops.Create.Img.class,
		Img.class, Dimensions.class, NativeType.class);
}
 
Example #25
Source File: DeconvolveNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Deprecated
public <I extends RealType<I>, O extends RealType<O> & NativeType<O>, K extends RealType<K>, C extends ComplexType<C>>
	RandomAccessibleInterval<O> richardsonLucyTV(
		final RandomAccessibleInterval<I> in,
		final RandomAccessibleInterval<K> kernel, final long[] borderSize,
		final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
		final OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel,
		final O outType, final C fftType, final int maxIterations,
		final float regularizationFactor)
{
	return richardsonLucyTV(create(in, outType), in, kernel, borderSize,
		obfInput, obfKernel, outType, fftType, maxIterations,
		regularizationFactor);
}
 
Example #26
Source File: CreateNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@OpMethod(
	ops = net.imagej.ops.create.imgFactory.DefaultCreateImgFactory.class)
public <T extends NativeType<T>> ImgFactory<T> imgFactory(
	final Dimensions dims)
{
	// NB: The generic typing of ImgFactory is broken; see:
	// https://github.com/imglib/imglib2/issues/91
	@SuppressWarnings("unchecked")
	final ImgFactory<T> result = (ImgFactory<T>) ops().run(
		Ops.Create.ImgFactory.class, dims);
	return result;
}
 
Example #27
Source File: DisplayImage.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public static < T extends RealType< T > & NativeType< T > > ImagePlus getImagePlusInstance(
		final RandomAccessibleInterval< T > img,
		final boolean virtualDisplay,
		final String title,
		final double min,
		final double max )
{
	ImagePlus imp = null;

	if ( img instanceof ImagePlusImg )
		try { imp = ((ImagePlusImg<T, ?>)img).getImagePlus(); } catch (ImgLibException e) {}

	if ( imp == null )
	{
		if ( virtualDisplay )
			imp = ImageJFunctions.wrap( img, title );
		else
			imp = ImageJFunctions.wrap( img, title ).duplicate();
	}

	imp.setTitle( title );
	imp.setDimensions( 1, (int)img.dimension( 2 ), 1 );
	imp.setDisplayRange( min, max );

	return imp;
}
 
Example #28
Source File: DeconvolveNamespace.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Deprecated
public <I extends RealType<I> & NativeType<I>, K extends RealType<K>>
	RandomAccessibleInterval<I> richardsonLucyTV(
		final RandomAccessibleInterval<I> in,
		final RandomAccessibleInterval<K> kernel, final long[] borderSize,
		final OutOfBoundsFactory<I, RandomAccessibleInterval<I>> obfInput,
		final OutOfBoundsFactory<K, RandomAccessibleInterval<K>> obfKernel,
		final int maxIterations, final float regularizationFactor)
{
	return richardsonLucyTV(create(in), in, kernel, borderSize, obfInput,
		obfKernel, maxIterations, regularizationFactor);
}
 
Example #29
Source File: StackListImageJ.java    From SPIM_Registration with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected StackImgLoader createAndInitImgLoader( final String path, final File basePath, final ImgFactory< ? extends NativeType< ? > > imgFactory, SequenceDescription sequenceDescription )
{
	return new StackImgLoaderIJ(
			new File( basePath.getAbsolutePath(), path ),
			fileNamePattern, imgFactory,
			hasMultipleTimePoints, hasMultipleChannels, hasMultipleIlluminations, hasMultipleAngles,
			sequenceDescription );
}
 
Example #30
Source File: TestImageAccessor.java    From Colocalisation_Analysis with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method creates a smoothed noise image that is made of
 * many little sticks oriented in a random direction. How many
 * of them and what the length of them are can be specified.
 *
 * @return a new noise image that is smoothed
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> produceSticksNoiseImageSmoothed(T type, int width,
		int height, int numSticks, int lineWidth, double maxLength, double[] smoothingSigma) {

	RandomAccessibleInterval<T> noiseImage = produceSticksNoiseImage(width, height, numSticks, lineWidth, maxLength);

	return gaussianSmooth(noiseImage, smoothingSigma);
}