• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RealViews类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getVisibleIds

import net.imglib2.realtransform.RealViews; //导入依赖的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


示例2: getInterpolatedSource

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
@Override
public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
	if( isTransformed )
	{
		final AffineTransform3D transform = new AffineTransform3D();
		source.getSourceTransform( t, level, transform );
		final RealRandomAccessible< T > sourceRealAccessible = RealViews.affineReal( source.getInterpolatedSource( t, level, method ), transform );
		if( xfm == null )
			return sourceRealAccessible;
		else
			return new RealTransformRealRandomAccessible< T, InverseRealTransform >( sourceRealAccessible, xfm );
	}
	else
	{
		return source.getInterpolatedSource( t, level, method );
	}
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:19,代码来源:WarpedSource.java


示例3: act

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
@Override
public < T extends RealType< T > > void act(
		final int iteration,
		final RandomAccessibleInterval< T > matrix,
		final RandomAccessibleInterval< T > scaledMatrix,
		final double[] lut,
		final int[] permutation,
		final int[] inversePermutation,
		final double[] multipliers,
		final RandomAccessibleInterval< double[] > estimatedFit )
{
	final T dummy = scaledMatrix.randomAccess().get().createVariable();
	dummy.setReal( Double.NaN );
	final String path = fileDir( iteration );
	if ( iteration == 0 )
		createParentDirectory( path );
	final LUTRealTransform tf = new LUTRealTransform( lut, 2, 2 );

	final RealTransformRealRandomAccessible< T, InverseRealTransform > transformed = RealViews.transformReal( Views.interpolate( Views.extendValue( scaledMatrix, dummy ), new NLinearInterpolatorFactory<>() ), tf );
	final double s = 1.0 / ( lut[ lut.length - 1 ] - lut[ 0 ] ) * lut.length;
	final double o = -lut[ 0 ];
	final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation( new double[] { s, s }, new double[] { o, o } );
	final IntervalView< T > offset = Views.interval( Views.raster( RealViews.transformReal( transformed, scaleAndTranslation ) ), scaledMatrix );
	final RandomAccessibleInterval< T > strip = MatrixStripConversion.matrixToStrip( offset, range, dummy );
	new FileSaver( ImageJFunctions.wrap( strip, "" ) ).saveAsTiff( path );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:27,代码来源:MatrixVisitor.java


示例4: main

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
final static public void main( final String[] args )
	{
		new ImageJ();
		final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
		imp.show();

		final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
		final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );

		final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
		for ( int i = 0; i < lut.length; ++i )
			lut[ i ] = i + Math.pow( i, 1.5 );

		final SingleDimensionLUTRealTransform transform = new SingleDimensionLUTRealTransform( lut, 2, 2, 1 );
		final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
		final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
		final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );

//		RealViews.transformReal(source, transform);

		ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
	}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:24,代码来源:SingleDimensionLUTRealTransform.java


示例5: getAccessor

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
/**
 * 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();
}
 
开发者ID:saalfeldlab,项目名称:render,代码行数:33,代码来源:AffineWarpField.java


示例6: fillMask

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
private < T extends BooleanType< T > > GrowingStoreRandomAccessibleSingletonAccess< T > fillMask( final AffineTransform3D tf, final long[] initialMin, final long[] initialMax, final Point p, final GrowingStoreRandomAccessibleSingletonAccess.Factory< T > factory, final T notVisited, final T fillLabel )
{
	final GrowingStoreRandomAccessibleSingletonAccess< T > tmpFill = new GrowingStoreRandomAccessibleSingletonAccess<>( initialMin, initialMax, factory, notVisited.createVariable() );

	final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels = new AccessBoxRandomAccessible<>(
			Views.extendValue(
					paintedLabels,
					new LongType( Label.TRANSPARENT ) ) );

	final AffineRandomAccessible< LongType, AffineGet > transformedPaintedLabels =
			RealViews.affine(
					Views.interpolate(
							accessTrackingExtendedPaintedLabels,
							new NearestNeighborInterpolatorFactory<>() ),
					tf );
	final MixedTransformView< LongType > hyperSlice = Views.hyperSlice( Views.raster( transformedPaintedLabels ), 2, 0 );

	final AffineRandomAccessible< LabelMultisetType, AffineGet > transformedLabels = RealViews.affine( Views.interpolate( Views.extendValue( labels, new LabelMultisetType() ), new NearestNeighborInterpolatorFactory<>() ), tf );
	final MixedTransformView< LabelMultisetType > hyperSliceLabels = Views.hyperSlice( Views.raster( transformedLabels ), 2, 0 );

	final RandomAccessiblePair< LabelMultisetType, LongType > labelsPaintedLabelsPair = new RandomAccessiblePair<>( hyperSliceLabels, hyperSlice );

	final RandomAccessiblePair< LabelMultisetType, LongType >.RandomAccess pairAccess = labelsPaintedLabelsPair.randomAccess();
	pairAccess.setPosition( p );
	final long seedPaint = pairAccess.get().getB().getIntegerLong();
	final long seedFragmentLabel = getBiggestLabel( pairAccess.getA() );

	FloodFill.fill( labelsPaintedLabelsPair, tmpFill, p, new ValuePair< LabelMultisetType, LongType >( new LabelMultisetType(), new LongType( selectionController.getActiveFragmentId() ) ), fillLabel, new DiamondShape( 1 ), new SegmentAndPaintFilter2D< T >( seedPaint, seedFragmentLabel, assignment ), new TypeWriter<>() );

	dirtyLabelsInterval.touch( accessTrackingExtendedPaintedLabels.createAccessInterval() );

	return tmpFill;
}
 
开发者ID:saalfeldlab,项目名称:bigcat,代码行数:34,代码来源:LabelFillController.java


示例7: writeMask

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
private void writeMask( final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFill, final AffineTransform3D tf, final long label )
{
	final IntervalView< BitType > tmpFillInterval = Views.interval( tmpFill, tmpFill.getIntervalOfSizeOfStore() );

	final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels = new AccessBoxRandomAccessible<>(
			Views.extendValue(
					paintedLabels,
					new LongType( Label.TRANSPARENT ) ) );

	final AffineRandomAccessible< LongType, AffineGet > transformedPaintedLabels =
			RealViews.affine(
					Views.interpolate(
							accessTrackingExtendedPaintedLabels,
							new NearestNeighborInterpolatorFactory<>() ),
					tf );
	final MixedTransformView< LongType > hyperSlice = Views.hyperSlice( Views.raster( transformedPaintedLabels ), 2, 0 );
	final net.imglib2.Cursor< BitType > s = tmpFillInterval.cursor();
	final net.imglib2.Cursor< LongType > t = Views.interval( hyperSlice, tmpFillInterval ).cursor();
	while ( s.hasNext() )
	{
		t.fwd();
		if ( s.next().get() )
			t.get().set( label );
	}

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


示例8: getVisibleIds

import net.imglib2.realtransform.RealViews; //导入依赖的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 );
	final IntervalView< Pair< LabelMultisetType, LongType > > screenLabels =
			Views.interval(
					Views.hyperSlice(
							RealViews.affine( labels, viewerTransform ), 2, 0 ),
					new FinalInterval( w, h ) );

	for ( final Pair< LabelMultisetType, LongType > pixel : Views.iterable( screenLabels ) )
	{
		final long b = pixel.getB().get();
		if ( b == Label.TRANSPARENT )
		{
			final LabelMultisetType a = pixel.getA();
			for ( final Entry< Label > entry : a.entrySet() )
				visibleIds.add( entry.getElement().id() );
		}
		else
			visibleIds.add( b );
	}

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


示例9: generateTransformed

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public static < T extends RealType< T > > RealRandomAccessible< T > generateTransformed(
		final RandomAccessibleInterval< T > input,
		final Transform permutation,
		final InvertibleRealTransform lut,
		final T dummy )
{
	dummy.setReal( Double.NaN );
	final IntervalView< T > permuted = Views.interval( new TransformView< T >( input, permutation ), input );
	final RealRandomAccessible< T > interpolated = Views.interpolate( Views.extendValue( permuted, dummy ), new NLinearInterpolatorFactory< T >() );
	return RealViews.transformReal( interpolated, lut );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:12,代码来源:ZPositionCorrection.java


示例10: generateStack

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public static < T extends RealType< T > > ImageStack generateStack(
		final RealRandomAccessible< T > input,
		final int width,
		final int height,
		final int size,
		final double zScale )
{
	final Scale3D scaleTransform = new Scale3D( 1.0, 1.0, zScale );
	final RealTransformRealRandomAccessible< T, InverseRealTransform > scaledInput = RealViews.transformReal( input, scaleTransform );
	final int scaledSize = ( int ) ( size * zScale );
	return generateStack( scaledInput, width, height, scaledSize );
}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:13,代码来源:ZPositionCorrection.java


示例11: AbstractLUTGrid

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public AbstractLUTGrid( final int numSourceDimensions, final int numTargetDimensions,
		final RandomAccessibleInterval< DoubleType > lutArray, final double[] scale, final double[] shift )
{
	super();
	this.numSourceDimensions = numSourceDimensions;
	this.numTargetDimensions = numTargetDimensions;
	this.lutArray = lutArray;

	// generate n-1 dimensional array that has local LUTs as columns
	final CompositeIntervalView< DoubleType, RealComposite< DoubleType > > collapsedSource = Views.collapseReal( lutArray );
	this.dimensions = new FinalInterval( collapsedSource );
	this.nNonTransformedCoordinates = this.dimensions.numDimensions();
	this.lutMaxIndex = ( int ) ( this.lutArray.dimension( this.nNonTransformedCoordinates ) ) - 1;

	// generate scale transform to allow for generating interpolated
	// high-res LUT from low-res LUT
	this.scale = new double[ this.nNonTransformedCoordinates ];
	this.shift = new double[ this.nNonTransformedCoordinates ];
	copyAndFillIfNecessary( scale, this.scale );
	copyAndFillIfNecessary( shift, this.shift );

	final ScaleAndTranslation scaleAndShift = new ScaleAndTranslation( this.scale, this.shift );
	final ExtendedRandomAccessibleInterval< RealComposite< DoubleType >, CompositeIntervalView< DoubleType, RealComposite< DoubleType > > > extendedCollapsedSource =
			Views.extendBorder( collapsedSource );
	this.coefficients = RealViews.transform( Views.interpolate( extendedCollapsedSource, this.interpolatorFactory ), scaleAndShift );
	this.access = this.coefficients.realRandomAccess();
	this.currentLut = this.access.get();

}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:30,代码来源:AbstractLUTGrid.java


示例12: main

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
final static public void main( final String[] args )
	{

		new ImageJ();
		final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
		imp.show();

		final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
		final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );

		final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
		for ( int i = 0; i < lut.length; ++i )
			lut[ i ] = i + Math.pow( i, 1.5 );

		final LUTRealTransform transform = new LUTRealTransform( lut, 2, 2 );
		final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
		final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
		final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );

//		RealViews.transformReal(source, transform);

		final ArrayImg< FloatType, FloatArray > targetImg = ArrayImgs.floats( imp.getWidth(), imp.getHeight() );
		render( source, targetImg, transform, 0.05 );

		ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
		ImageJFunctions.show( targetImg );
	}
 
开发者ID:saalfeldlab,项目名称:z-spacing,代码行数:29,代码来源:LUTRealTransform.java


示例13: calculate

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
@Override
public RandomAccessibleInterval<T> calculate(RandomAccessibleInterval<T> input) {
	final long[] newDims = Intervals.dimensionsAsLongArray(in());
	for (int i = 0; i < Math.min(scaleFactors.length, in().numDimensions()); i++) {
		newDims[i] = Math.round(in().dimension(i) * scaleFactors[i]);
	}

	IntervalView<T> interval = Views.interval(Views.raster(RealViews.affineReal(
		Views.interpolate(Views.extendMirrorSingle(input), interpolator),
		new Scale(scaleFactors))), new FinalInterval(newDims));

	return interval;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:14,代码来源:DefaultScaleView.java


示例14: xfmToView

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public static <T extends RealType<T>> RealTransformRandomAccessible<T, InverseRealTransform> xfmToView(
		InvertibleRealTransform xfm, 
		RandomAccessible<T> src, 
		InterpolatorFactory<T, RandomAccessible<T>> interpFactory) 
{
	RealRandomAccessible<T> interpolant = Views.interpolate(
			src, interpFactory);

	RealTransformRandomAccessible<T, InverseRealTransform> rv = 
		RealViews.transform( interpolant, xfm.inverse() );

	return rv;
}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:14,代码来源:TransformTools.java


示例15: getTransformedSource

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
protected static < T, A extends AffineGet & Concatenable< AffineGet > > RandomAccessible< T > getTransformedSource( final AffineTransformType< A > transformType, final RenderSource< T, A > source, final A viewerTransform, final A screenScaleTransform ) {
    final RealRandomAccessible< T > img = source.getInterpolatedSource();

    final A sourceToScreen = transformType.createTransform();
    transformType.set( sourceToScreen, screenScaleTransform );
    sourceToScreen.concatenate( viewerTransform );
    sourceToScreen.concatenate( source.getSourceTransform() );

    return RealViews.affine( img, sourceToScreen );
}
 
开发者ID:fjug,项目名称:IDDEA,代码行数:11,代码来源:InjectableMultiResolutionRenderer.java


示例16: getTransformedSource

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
private static < T extends NumericType< T > > RandomAccessible< T > getTransformedSource( final ViewerState viewerState, final Source< T > source, final AffineTransform3D screenScaleTransform, final int mipmapIndex )
{
	final int timepoint = viewerState.getCurrentTimepoint();
	final Interpolation interpolation = viewerState.getInterpolation();
	final RealRandomAccessible< T > img = source.getInterpolatedSource( timepoint, mipmapIndex, interpolation );

	final AffineTransform3D sourceToScreen = new AffineTransform3D();
	viewerState.getViewerTransform( sourceToScreen );
	sourceToScreen.concatenate( source.getSourceTransform( timepoint, mipmapIndex ) );
	sourceToScreen.preConcatenate( screenScaleTransform );

	return RealViews.constantAffine( img, sourceToScreen );
}
 
开发者ID:tpietzsch,项目名称:TileServer,代码行数:14,代码来源:TileRenderer.java


示例17: main

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public static void main(String[] args)
{
	RandomAccessibleInterval< FloatType > a = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
	RandomAccessibleInterval< FloatType > b = ImgLib2Util.openAs32Bit( new File( "74.tif.zip" ) );
	
	long slice = 40;
	ImageJFunctions.show( a );
	
	a = Views.zeroMin( Views.hyperSlice( a, 2, slice ));
	b = Views.zeroMin( Views.hyperSlice( b, 2, slice ));

	TranslationGet t1 = new Translation2D();
	TranslationGet t2 = new Translation2D(460, 0);
	ArrayList< Pair< RealInterval, AffineGet > > views = new ArrayList<Pair<RealInterval, AffineGet>>();
	views.add( new ValuePair< RealInterval, AffineGet >( a, t1 ) );
	views.add( new ValuePair< RealInterval, AffineGet >( b, t2 ) );

	RealInterval overlap = BoundingBoxMaximalGroupOverlap.getMinBoundingIntervalSingle( views );

	final RealInterval transformed1 = TransformTools.applyTranslation( a, t1, new boolean[] {false, false} );
	final RealInterval transformed2 = TransformTools.applyTranslation( b, t2, new boolean[] {false, false} );

	// get overlap in images' coordinates
	final RealInterval localOverlap1 = TransformTools.getLocalOverlap( transformed1, overlap );
	final RealInterval localOverlap2 = TransformTools.getLocalOverlap( transformed2, overlap );

	// round to integer interval
	final Interval interval1 = TransformTools.getLocalRasterOverlap( localOverlap1 );
	final Interval interval2 = TransformTools.getLocalRasterOverlap( localOverlap2 );

	//final WarpFunction warp = new TranslationWarp(3);
	final WarpFunction warp = new RigidWarp(2);
	//final WarpFunction warp = new AffineWarp( 3 );

	// rotate second image
	AffineTransform2D rot = new AffineTransform2D();
	rot.rotate( 1.4 * Math.PI / 180 );
	RandomAccessibleInterval< FloatType > rotated = Views.interval(
			RealViews.affine( 
					Views.interpolate( Views.extendMirrorSingle( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
					rot.copy() ),
			interval2);

	// show input
	new ImageJ();
	ImageJFunctions.show( Views.interval( a,  interval1 ) );
	ImageJFunctions.show( rotated );

	// downsample input
	RandomAccessibleInterval< FloatType > simple2x1 = Downsample.simple2x( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), new boolean[] {false, false} );
	RandomAccessibleInterval< FloatType > simple2x2 = Downsample.simple2x( Views.zeroMin( Views.interval( rotated, interval2 ) ), new ArrayImgFactory<>(), new boolean[] {false, false} );

	// align

	//Align< FloatType > lk = new Align<>( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), warp );
	Align< FloatType > lk = new Align<>( simple2x1, new ArrayImgFactory<>(), warp );
	//System.out.println( Util.printCoordinates( lk.align( Views.zeroMin( Views.interval( b, interval2 ) ), 100, 0.01 ).getRowPackedCopy() ) );
	//final AffineTransform transform = lk.align( Views.zeroMin( rotated ), 100, 0.01 );
	final AffineTransform transform = lk.align( simple2x2, 100, 0.1 );

	// transformation matrix
	System.out.println( Util.printCoordinates( transform.getRowPackedCopy() ) );

	// correct input and show
	RandomAccessibleInterval< FloatType > backRotated = Views.interval(
			RealViews.affine( 
					Views.interpolate( Views.extendMirrorSingle( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
					rot.copy().preConcatenate( transform ).copy() ),
			interval2);

	ImageJFunctions.show( backRotated );

	// constructor needs column packed matrix, therefore the transpose
	Matrix mt = new Matrix( transform.getRowPackedCopy(), 3).transpose();
	Matrix rigid = mt.getMatrix( 0, 1, 0, 1 );

	// check whether result is rotation matrix (det == +-1, orthogonal)
	System.out.println( rigid.det() );
	System.out.println( Util.printCoordinates( rigid.times( rigid.transpose() ).getRowPackedCopy() ) );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:81,代码来源:RigidWarp.java


示例18: getCurrentCorrelation

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public double getCurrentCorrelation(final RandomAccessibleInterval< T > image)
{
	final RealRandomAccessible< T > interpolated = Views.interpolate( Views.extendBorder( image ), new NLinearInterpolatorFactory< T >() );
	final RandomAccessible< T > warped = RealViews.affine( interpolated, currentTransform );
	return PhaseCorrelation2Util.getCorrelation( Views.interval( warped, template ), template );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:7,代码来源:Align.java


示例19: computeDifference

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
/**
 * Compute the pixel-wise difference between an affine-transformed source
 * image and a target image.
 *
 * @param source
 *            The source image.
 * @param transform
 *            A coordinate transformation to apply to the source image.
 * @param target
 *            The target image.
 * @param difference
 *            Output image. The pixel-wise difference between the
 *            transformed source image and the target image is stored here.
 *            
 * @param <T> pixel type source
 * @param <S> pixel type target
 */
public static < T extends RealType< T >,  S extends RealType< S > > void computeDifference(
		final RandomAccessible< T > source,
		final AffineTransform transform,
		final RandomAccessible< T > target,
		final RandomAccessibleInterval< S > difference,
		final ExecutorService service,
		final int nTasks)
{
	final RealRandomAccessible< T > interpolated = Views.interpolate( source, new NLinearInterpolatorFactory< T >() );
	final RandomAccessible< T > warped = RealViews.affine( interpolated, transform );

	final long stepSize = Views.iterable( difference ).size() / nTasks;

	final List<Callable< Void >> tasks = new ArrayList<>();
	final AtomicInteger ai = new AtomicInteger( 0 );
	for (int iO = 0; iO<nTasks; iO++)
	{
		tasks.add( new Callable< Void >()
		{
			@Override
			public Void call() throws Exception
			{
				final int i = ai.getAndIncrement();
				final Cursor< T > cw = Views.flatIterable( Views.interval( warped, difference ) ).cursor();
				final Cursor< T > ct = Views.flatIterable( Views.interval( target, difference ) ).cursor();
				final Cursor< S > cd = Views.flatIterable( difference ).cursor();

				cw.jumpFwd( stepSize * i );
				ct.jumpFwd( stepSize * i );
				cd.jumpFwd( stepSize * i );

				final long end = i == nTasks - 1 ? Views.iterable( difference ).size() - stepSize * i : stepSize;
				int count = 0;
				while (count++ < end)
				{
					cd.next().setReal( ( cw.next().getRealDouble() - ct.next().getRealDouble() ));
				}
				return null;
			}
		} );
	}

	try
	{
		List< Future< Void > > futures = service.invokeAll( tasks );
		for (Future< Void > f: futures)
			f.get();
	}
	catch ( InterruptedException | ExecutionException e )
	{
		e.printStackTrace();
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:71,代码来源:Align.java


示例20: main

import net.imglib2.realtransform.RealViews; //导入依赖的package包/类
public static void main(String[] args)
{
	Img< FloatType > a = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
	Img< FloatType > b = ImgLib2Util.openAs32Bit( new File( "74.tif.zip" ) );

	TranslationGet t1 = new Translation3D();
	TranslationGet t2 = new Translation3D(460, 0, 0);
	ArrayList< Pair< RealInterval, AffineGet > > views = new ArrayList<Pair<RealInterval, AffineGet>>();
	views.add( new ValuePair< RealInterval, AffineGet >( a, t1 ) );
	views.add( new ValuePair< RealInterval, AffineGet >( b, t2 ) );

	RealInterval overlap = BoundingBoxMaximalGroupOverlap.getMinBoundingIntervalSingle( views );

	final RealInterval transformed1 = TransformTools.applyTranslation( a, t1, new boolean[] {false, false, false} );
	final RealInterval transformed2 = TransformTools.applyTranslation( b, t2, new boolean[] {false, false, false} );

	// get overlap in images' coordinates
	final RealInterval localOverlap1 = TransformTools.getLocalOverlap( transformed1, overlap );
	final RealInterval localOverlap2 = TransformTools.getLocalOverlap( transformed2, overlap );

	// round to integer interval
	final Interval interval1 = TransformTools.getLocalRasterOverlap( localOverlap1 );
	final Interval interval2 = TransformTools.getLocalRasterOverlap( localOverlap2 );

	//final WarpFunction warp = new TranslationWarp(3);
	final WarpFunction warp = new RigidWarp(3);
	//final WarpFunction warp = new AffineWarp( 3 );

	// rotate second image
	AffineTransform3D rot = new AffineTransform3D();
	rot.rotate( 2, 2 * Math.PI / 180 );
	RandomAccessibleInterval< FloatType > rotated = Views.interval(
			RealViews.affine( 
					Views.interpolate( Views.extendBorder( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
					rot.copy() ),
			interval2);

	// show input
	new ImageJ();
	ImageJFunctions.show( Views.interval( a,  interval1 ), "target" );
	ImageJFunctions.show( rotated, "in");

	// downsample input
	RandomAccessibleInterval< FloatType > simple2x1 = Downsample.simple2x( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), new boolean[] {true, true, false} );
	RandomAccessibleInterval< FloatType > simple2x2 = Downsample.simple2x( Views.zeroMin( Views.interval( rotated, interval2 ) ), new ArrayImgFactory<>(), new boolean[] {true, true, false} );

	// align

	//Align< FloatType > lk = new Align<>( Views.zeroMin( Views.interval( a, interval1 ) ), new ArrayImgFactory<>(), warp );
	Align< FloatType > lk = new Align<>( simple2x1, new ArrayImgFactory<>(), warp );
	//System.out.println( Util.printCoordinates( lk.align( Views.zeroMin( Views.interval( b, interval2 ) ), 100, 0.01 ).getRowPackedCopy() ) );
	//final AffineTransform transform = lk.align( Views.zeroMin( rotated ), 100, 0.01 );
	final AffineTransform transform = lk.align( simple2x2, 100, 0.01 );

	final AffineTransform scale = new AffineTransform( 3 );
	scale.set( 2, 0, 0 );
	scale.set( 1, 1, 1 );

	transform.preConcatenate( scale );

	// transformation matrix
	System.out.println( Util.printCoordinates( transform.getRowPackedCopy() ) );

	// correct input and show
	RandomAccessibleInterval< FloatType > backRotated = Views.interval(
			RealViews.affine( 
					Views.interpolate( Views.extendBorder( Views.zeroMin( Views.interval( b, interval2 ) ) ), new NLinearInterpolatorFactory<>() ),
					rot.copy().preConcatenate( transform ).copy() ),
			interval2);

	ImageJFunctions.show( backRotated, "out" );

	// constructor needs column packed matrix, therefore the transpose
	Matrix mt = new Matrix( transform.getRowPackedCopy(), 4).transpose();
	Matrix rigid = mt.getMatrix( 0, 2, 0, 2 );

	// check whether result is rotation matrix (det == +-1, orthogonal)
	System.out.println( rigid.det() );
	System.out.println( Util.printCoordinates( rigid.times( rigid.transpose() ).getRowPackedCopy() ) );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:81,代码来源:Align.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RollEditsResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java Keyspace类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap