当前位置: 首页>>代码示例>>Java>>正文


Java Views类代码示例

本文整理汇总了Java中net.imglib2.view.Views的典型用法代码示例。如果您正苦于以下问题:Java Views类的具体用法?Java Views怎么用?Java Views使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Views类属于net.imglib2.view包,在下文中一共展示了Views类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: reorder

import net.imglib2.view.Views; //导入依赖的package包/类
private static <T extends RealType<T>> RandomAccessibleInterval<T> reorder(
	RandomAccessibleInterval<T> image, int[] dimOrder)
{
	RandomAccessibleInterval<T> output = image;

	// Array which contains for each dimension information on which dimension it is right now
	int[] moved = IntStream.range(0, image.numDimensions()).toArray();

	// Loop over all dimensions and move it to the right spot
	for (int i = 0; i < image.numDimensions(); i++) {
		int from = moved[i];
		int to = dimOrder[i];

		// Move the dimension to the right dimension
		output = Views.permute(output, from, to);

		// Now we have to update which dimension was moved where
		moved[i] = to;
		moved = Arrays.stream(moved).map(v -> v == to ? from : v).toArray();
	}
	return output;
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:23,代码来源:Tensors.java

示例2: setUpBeforeClass

import net.imglib2.view.Views; //导入依赖的package包/类
/**
 * @throws java.lang.Exception
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {

	final File testDir = new File(testDirPath);
	testDir.mkdirs();
	if (!(testDir.exists() && testDir.isDirectory()))
		throw new IOException("Could not create benchmark directory for HDF5Utils benchmark.");

	data = new short[64 * 64 * 64];
	final ImagePlus imp = new Opener().openURL("https://imagej.nih.gov/ij/images/t1-head-raw.zip");
	final ImagePlusImg<UnsignedShortType, ?> img = (ImagePlusImg<UnsignedShortType, ?>)(Object)ImagePlusImgs.from(imp);
	final Cursor<UnsignedShortType> cursor = Views.flatIterable(Views.interval(img, new long[]{100, 100, 30}, new long[]{163, 163, 93})).cursor();
	for (int i = 0; i < data.length; ++i)
		data[i] = (short)cursor.next().get();

	n5 = new N5FSWriter(testDirPath);
}
 
开发者ID:saalfeldlab,项目名称:n5,代码行数:21,代码来源:N5Benchmark.java

示例3: applySplit

import net.imglib2.view.Views; //导入依赖的package包/类
/**
 * Splits a subspace along the given coordinates
 * <p>
 * For example, if you have a 5D {X, Y, Z, C, T} hyperstack, and give the
 * coordinates {{3, 0}, {4, 1}} you'll get a 3D {X, Y, Z} subspace of the
 * first channel, and second time frame
 * </p>
 * 
 * @param hyperstack an n-dimensional image
 * @param splitCoordinates (dimension, position) pairs describing the
 *          hyperstack split
 * @return The subspace interval
 */
private static <T extends RealType<T> & NativeType<T>>
	RandomAccessibleInterval<T> applySplit(final ImgPlus<T> hyperstack,
		final List<ValuePair<IntType, LongType>> splitCoordinates)
{
	final List<ValuePair<IntType, LongType>> workingSplit = createWorkingCopy(
		splitCoordinates);
	RandomAccessibleInterval<T> slice = hyperstack;
	for (int i = 0; i < workingSplit.size(); i++) {
		final int dimension = workingSplit.get(i).a.get();
		final long position = workingSplit.get(i).b.get();
		slice = Views.hyperSlice(slice, dimension, position);
		decrementIndices(workingSplit, dimension);
	}
	return slice;
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:29,代码来源:HyperstackUtils.java

示例4: testCube

import net.imglib2.view.Views; //导入依赖的package包/类
/**
 * Tests the op on a cube. All vectors should enter and exit it, i.e. their
 * length should be 0.5.
 */
@Test
public void testCube() {
	final Img<BitType> cube = ArrayImgs.bits(100, 100, 100);
	final IntervalView<BitType> foreground = Views.interval(cube, new long[] {
		1, 1, 1 }, new long[] { 98, 98, 98 });
	foreground.cursor().forEachRemaining(BitType::setOne);
	final double expectedLength = 1.0 / 2.0;

	@SuppressWarnings("unchecked")
	final List<Vector3d> milVectors =
		(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
			cube, IDENTITY_ROTATION, 10L, DEFAULT_INCREMENT, new Random(0xc0ff33)))
				.get(0);

	assertEquals("Regression test failed: some vectors have unexpected length",
		milVectors.size(), milVectors.stream().filter(v -> v
			.length() == expectedLength).count());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:23,代码来源:MILGridTest.java

示例5: testXZSheets

import net.imglib2.view.Views; //导入依赖的package包/类
@Test
public void testXZSheets() {
	// SETUP
	final Img<BitType> sheets = ArrayImgs.bits(100, 100, 100);
	// Draw 19 XZ sheets
	final long numSheets = 19;
	for (long y = 5; y < 100; y += 5) {
		final IntervalView<BitType> sheet = Views.interval(sheets, new long[] { 0,
			y, 0 }, new long[] { 99, y, 99 });
		sheet.cursor().forEachRemaining(BitType::setOne);
	}

	// EXECUTE
	@SuppressWarnings("unchecked")
	final List<Vector3d> milVectors =
		(List<Vector3d>) ((ArrayList<Object>) IMAGE_J.op().run(MILGrid.class,
			sheets, IDENTITY_ROTATION, DEFAULT_BINS, DEFAULT_INCREMENT, new Random(
				0xc0ff33))).get(0);

	// VERIFY
	final Stream<Vector3d> yVectors = milVectors.stream().filter(v -> isParallel
		.test(v, new Vector3d(0, 1, 0)));
	assertTrue("MIL vectors in the Y-direction have unexpected length", yVectors
		.allMatch(v -> v.length() == 1.0 / (2 * numSheets)));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:26,代码来源:MILGridTest.java

示例6: Align

import net.imglib2.view.Views; //导入依赖的package包/类
public Align(final RandomAccessibleInterval< T > template, final ImgFactory< FloatType > factory, WarpFunction model)
{
	this.template = template;

	n = template.numDimensions();
	warpFunction = model;
	numParameters = warpFunction.numParameters();
	
	currentTransform = new AffineTransform( n );
	
	final long[] dim = new long[n + 1];
	for ( int d = 0; d < n; ++d )
		dim[d] = template.dimension( d );
	dim[n] = n;
	final Img< FloatType > gradients = factory.create( dim, new FloatType() );
	gradients( Views.extendBorder( template ), gradients );

	dim[n] = numParameters;
	descent = factory.create( dim, new FloatType() );
	computeSteepestDescents( gradients, warpFunction, descent );

	Hinv = computeInverseHessian( descent );

	error = factory.create( template, new FloatType() );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:Align.java

示例7: gradient

import net.imglib2.view.Views; //导入依赖的package包/类
/**
 * Compute the partial derivative of source in a particular dimension.
 *
 * @param source
 *            source image, has to provide valid data in the interval of the
 *            gradient image plus a one pixel border in dimension.
 * @param target
 *            output image, the partial derivative of source in the
 *            specified dimension.
 * @param dimension
 *            along which dimension the partial derivatives are computed
 * @param <T> pixel type source
 * @param <S> pixel type target
 */
public static < T extends RealType< T >, S extends RealType< S > > void gradient(
		final RandomAccessible< T > source,
		final RandomAccessibleInterval< S > target,
		final int dimension )
{
	final Cursor< T > front = Views.flatIterable(
			Views.interval( source,
					Intervals.translate( target, 1, dimension ) ) ).cursor();
	final Cursor< T > back = Views.flatIterable(
			Views.interval( source,
					Intervals.translate( target, -1, dimension ) ) ).cursor();
	for( final S t : Views.flatIterable( target ) )
	{
		t.setReal( front.next().getRealDouble() - back.next().getRealDouble());
		t.mul( 0.5 );
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:32,代码来源:Align.java

示例8: calculatePCM

import net.imglib2.view.Views; //导入依赖的package包/类
public static <T extends RealType<T>, S extends RealType<S>, R extends RealType<R>, C extends ComplexType<C>> RandomAccessibleInterval<R> calculatePCM(
		RandomAccessibleInterval<T> img1, RandomAccessibleInterval<S> img2, int[] extension,
		ImgFactory<R> factory, R type, ImgFactory<C> fftFactory, C fftType, ExecutorService service){

	
	// TODO: Extension absolute per dimension in pixels, i.e. int[] extension
	// TODO: not bigger than the image dimension because the second mirroring is identical to the image
	
	Dimensions extSize = PhaseCorrelation2Util.getExtendedSize(img1, img2, extension);
	long[] paddedDimensions = new long[extSize.numDimensions()];
	long[] fftSize = new long[extSize.numDimensions()];
	FFTMethods.dimensionsRealToComplexFast(extSize, paddedDimensions, fftSize);
	
	RandomAccessibleInterval<C> fft1 = fftFactory.create(fftSize, fftType);
	RandomAccessibleInterval<C> fft2 = fftFactory.create(fftSize, fftType);
	
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img1, extension), 
			FFTMethods.paddingIntervalCentered(img1, new FinalInterval(paddedDimensions))), fft1, service);
	FFT.realToComplex(Views.interval(PhaseCorrelation2Util.extendImageByFactor(img2, extension), 
			FFTMethods.paddingIntervalCentered(img2, new FinalInterval(paddedDimensions))), fft2, service);
	
	RandomAccessibleInterval<R> pcm = calculatePCMInPlace(fft1, fft2, factory, type, service);
	return pcm;
	
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:PhaseCorrelation2.java

示例9: click

import net.imglib2.view.Views; //导入依赖的package包/类
@Override
public void click( final int x, final int y )
{
	if ( filledPixelsOverlay.visible() )
	{
		synchronized ( viewer )
		{
			viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );

			final Point p = new Point( x, y );

			final ArrayImg< ByteType, ByteArray > img = wrapBufferedImage( filledPixelsOverlay.img );

			final ByteType extension = new ByteType( ( byte ) 1 );

			final long t0 = System.currentTimeMillis();
			final ArrayRandomAccess< ByteType > ra = img.randomAccess();
			ra.setPosition( p );
			FloodFill.fill( Views.extendValue( img, extension ), Views.extendValue( img, extension ), p, extension.copy(), extension.copy(), new DiamondShape( 1 ), filter );
			final long t1 = System.currentTimeMillis();
			System.out.println( "Filling took " + ( t1 - t0 ) + " ms" );
			viewer.setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
			viewer.getDisplay().repaint();
		}
	}
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:27,代码来源:DrawProjectAndIntersectController.java

示例10: paint

import net.imglib2.view.Views; //导入依赖的package包/类
protected void paint( final RealLocalizable coords)
{
	final AccessBoxRandomAccessible< LongType > accessBoxExtendedLabels = new AccessBoxRandomAccessible<>( extendedLabels );
	final RandomAccessible< LongType > labelSource = Views.hyperSlice( accessBoxExtendedLabels, brushNormalAxis, Math.round( coords.getDoublePosition( 2 ) ) );

	final Neighborhood< LongType > sphere =
			HyperSphereNeighborhood.< LongType >factory().create(
					new long[]{
							Math.round( coords.getDoublePosition( brushNormalAxis == 0 ? 1 : 0 ) ),
							Math.round( coords.getDoublePosition( brushNormalAxis == 2 ? 1 : 2 ) ) },
					Math.round( brushRadius / Affine3DHelpers.extractScale( labelTransform, brushNormalAxis == 0 ? 1 : 0 ) ),
					labelSource.randomAccess() );

	for ( final LongType t : sphere )
		t.set( getValue() );

	dirtyLabelsInterval.touch( accessBoxExtendedLabels.createAccessInterval() );
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:19,代码来源:LabelBrushController.java

示例11: intersect

import net.imglib2.view.Views; //导入依赖的package包/类
public static < T, U, V > void intersect(
			final RandomAccessibleInterval< T > source1,
			final RandomAccessibleInterval< U > source2,
			final RandomAccessibleInterval< V > target,
//			Filter< T, U > filter, // can be handled in writer? only writer: requires write for every pixel but simpler interface
			final Converter< Pair< T, U >, V > writer )
	{
		final RandomAccessiblePair< T, U > sourcesPair = new RandomAccessiblePair< >( source1, source2 );
		final RandomAccessiblePair< Pair< T, U >, V > sourcesTargetPair = new RandomAccessiblePair< >( sourcesPair, target );

		for ( final Pair< Pair< T, U >, V > entry : Views.interval( sourcesTargetPair, target ) )
		{
			final Pair< T, U > sources = entry.getA();
			writer.convert( sources, entry.getB() );
		}
	}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:17,代码来源:LabelRestrictToSegmentController.java

示例12: getVisibleIds

import net.imglib2.view.Views; //导入依赖的package包/类
@Override
public synchronized TLongHashSet getVisibleIds()
{
	final TLongHashSet visibleIds = new TLongHashSet();
	final int w = viewer.getWidth();
	final int h = viewer.getHeight();
	final AffineTransform3D viewerTransform = new AffineTransform3D();
	viewer.getState().getViewerTransform( viewerTransform );
	IntervalView< LabelMultisetType > screenLabels =
			Views.interval(
					Views.hyperSlice(
							RealViews.affine( labels, viewerTransform ), 2, 0 ),
					new FinalInterval( w, h ) );

	for ( final LabelMultisetType pixel : Views.iterable( screenLabels ) )
	{
		for ( final Entry< Label > entry : pixel.entrySet() )
				visibleIds.add( entry.getElement().id() );
	}

	return visibleIds;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:23,代码来源:LabelMultiSetIdPicker.java

示例13: get

import net.imglib2.view.Views; //导入依赖的package包/类
@Override
		public RandomAccessibleInterval< T > get()
		{
			long[] lower = position.clone();
			long[] upper = new long[ lower.length ];
			for ( int d = 0; d < lower.length; d++ )
			{
				long m = min[ d ];
				long s = stepSize[ d ];
				long val = ( lower[ d ] - m ) * s + m;
				lower[ d ] = val;
				upper[ d ] = val + s - 1; // -1 if not offsetInterval
				// if offsetInterval, use stepSize instead of upper
			}
			// use offsetInterval?
			return Views.offsetInterval( extendedSource, lower, stepSize );
//			return Views.interval( extendedSource, lower, upper );
		}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:19,代码来源:BlockedInterval.java

示例14: minMax

import net.imglib2.view.Views; //导入依赖的package包/类
public double[] minMax()
{
	double[] minmax = new double[ 2 ];
	minmax[ 0 ] = Double.MAX_VALUE;
	minmax[ 1 ] = Double.MIN_VALUE;
	
	Cursor<T> curs = Views.iterable( this.getSource( 0,0 ) ).cursor();
	
	while( curs.hasNext() )
	{
		double val = curs.next().getRealDouble();
		if( val < minmax[ 0 ])
			minmax[ 0 ] = val;
		else if( val > minmax[ 1 ])
			minmax[ 1 ] = val;
		
	}
	return minmax;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:20,代码来源:WarpMagnitudeSource.java

示例15: execute

import net.imglib2.view.Views; //导入依赖的package包/类
@Override
public void execute(DataContainer<T> container)
		throws MissingPreconditionException {
	double mean1 = container.getMeanCh1();
	double mean2 = container.getMeanCh2();

	// get the 2 images for the calculation of Li's ICQ
	RandomAccessible<T> img1 = container.getSourceImage1();
	RandomAccessible<T> img2 = container.getSourceImage2();
	RandomAccessibleInterval<BitType> mask = container.getMask();

	TwinCursor<T> cursor = new TwinCursor<T>(img1.randomAccess(),
			img2.randomAccess(), Views.iterable(mask).localizingCursor());
	// calculate ICQ value
	icqValue = calculateLisICQ(cursor, mean1, mean2);
}
 
开发者ID:fiji,项目名称:Colocalisation_Analysis,代码行数:17,代码来源:LiICQ.java


注:本文中的net.imglib2.view.Views类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。