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

Java RealInterval类代码示例

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

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



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

示例1: applyTranslation

import net.imglib2.RealInterval; //导入依赖的package包/类
public static FinalRealInterval applyTranslation(RealInterval img, TranslationGet translation, boolean[] ignoreDims){

		// get number of dimensions we actually use
		int n = 0;
		for (int d = 0; d < ignoreDims.length; ++d)
			if (!ignoreDims[d])
				n++;
		
		final double [] min = new double [n];
		final double [] max = new double [n];
		
		int i2 = 0;
		for (int i = 0; i< img.numDimensions();++i)
		{
			if (!ignoreDims[i])
			{
				min[i2] = img.realMin(i) + translation.getTranslation(i);
				max[i2] = img.realMax(i) + translation.getTranslation(i);
				i2++;
			}
		}
		return new FinalRealInterval(min, max);
	}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:24,代码来源:TransformTools.java


示例2: getLocalRasterOverlap

import net.imglib2.RealInterval; //导入依赖的package包/类
/**
 * create an integer interval from real interval, being conservatie on the size
 * (min is ceiled, max is floored)
 * @param overlap real input
 * @return interger interval, with mins ceiled and maxs floored
 */
public static FinalInterval getLocalRasterOverlap(RealInterval overlap)
{
	final int n = overlap.numDimensions();
	final long [] min = new long [n];
	final long [] max = new long [n];
	
	for (int i = 0; i< n; i++)
	{
		// round down errors when it is exactly 0.5, if we do not do this we end up with two intervals
		// of different size, e.g.:
		// if the first interval starts at 139.5 going to 199, the second one at 0.0 going to 59.5
		// then the rastered 1st would go from round(139.5)=140 + 1 = 141 -to- round(199)=199 - 1 = 198, dim=58
		// and  the rastered 2nd would go from round(0.0)=0 + 1     =   1 -to- round(59.5)=60 - 1 = 59,  dim=59
		min[i] = Math.round((overlap.realMin(i) - 0.0001 )) + 1;
		max[i] = Math.round((overlap.realMax(i) + 0.0001 )) - 1;
	}
	
	return new FinalInterval(min, max);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:26,代码来源:TransformTools.java


示例3: getOverlap

import net.imglib2.RealInterval; //导入依赖的package包/类
public static FinalRealInterval getOverlap(final RealInterval img1, final RealInterval img2){
	final int n = img1.numDimensions();
	final double [] min = new double [n];
	final double [] max = new double [n];
	
	for (int i = 0; i< n; i++)
	{
		min[i] = Math.max(img1.realMin(i), img2.realMin(i));
		max[i] = Math.min(img1.realMax(i), img2.realMax(i));
		
		// intervals do not overlap
		if ( max[i] < min [i])
			return null;
	}
	
	return new FinalRealInterval(min, max);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:18,代码来源:TransformTools.java


示例4: exec

import net.imglib2.RealInterval; //导入依赖的package包/类
public void exec( final String xmlHDF5Path, final int setupID, final String tgmmPath, final String outputPath, final boolean doCrop, final RealInterval interval, final int tFrom, final int tTo )
{
	SpimDataMinimal spimData;
	try
	{
		spimData = new XmlIoSpimDataMinimal().load( xmlHDF5Path );
	}
	catch ( final SpimDataException e )
	{
		logger.error( "Problem reading the transforms in image data file:\n" + e.getMessage() + "\n" );
		return;
	}
	final Model model = createModel( new File( tgmmPath ), spimData, setupID, interval, tFrom, tTo );
	model.setLogger( logger );
	final Settings settings = createSettings( new File( xmlHDF5Path ) );

	final TrackMate trackmate = new TrackMate( model, settings );
	trackmate.setNumThreads( 1 );
	trackmate.computeSpotFeatures( true );
	trackmate.computeEdgeFeatures( true );
	trackmate.computeTrackFeatures( true );

	save( outputPath, model, settings );
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:25,代码来源:ImportTGMMAnnotationPlugin_.java


示例5: launchMamut

import net.imglib2.RealInterval; //导入依赖的package包/类
public void launchMamut( final File imageFile, final File tgmmFile, final int setupID, final RealInterval interval )
{
	SpimDataMinimal spimData;
	try
	{
		spimData = new XmlIoSpimDataMinimal().load( imageFile.getAbsolutePath() );
	}
	catch ( final SpimDataException e )
	{
		logger.error( "Problem reading the transforms in image data file:\n" + e.getMessage() + "\n" );
		return;
	}
	final Model model = createModel( tgmmFile, spimData, setupID, interval );
	final SourceSettings settings = createSettings();
	new MaMuT( imageFile, model, settings );
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:17,代码来源:LoadTGMMAnnotationPlugIn.java


示例6: createModel

import net.imglib2.RealInterval; //导入依赖的package包/类
protected Model createModel( final File tgmmFolder, final SpimDataMinimal spimData, final int setupID, final RealInterval interval )
{
	final List< AffineTransform3D > transforms = pickTransform( spimData, setupID );

	final TGMMImporter2 importer = new TGMMImporter2( tgmmFolder, transforms, TGMMImporter2.DEFAULT_PATTERN, logger, interval, 0, Integer.MAX_VALUE );
	if ( !importer.checkInput() || !importer.process() )
	{
		logger.error( importer.getErrorMessage() );
		return new Model();
	}
	final Model model = importer.getResult();

	/*
	 * Hack to set the POSITION_T feature of imported spots.
	 */
	final Settings settings = new Settings();
	settings.dt = 1;
	final TrackMate trackmate = new TrackMate( model, settings );
	final ResetSpotTimeFeatureAction action = new ResetSpotTimeFeatureAction();
	action.execute( trackmate );

	return model;
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:24,代码来源:LoadTGMMAnnotationPlugIn.java


示例7: getLocalOverlap

import net.imglib2.RealInterval; //导入依赖的package包/类
/**
 * get overlap in local image coordinates (assuming min = (0,0,..))
 * @param img image interval (global coordinates)
 * @param overlap overlap interval (global coordinates)
 * @return overlap interval  in local coordinates
 */
public static FinalRealInterval getLocalOverlap(RealInterval img, RealInterval overlap){
	final int n = img.numDimensions();
	final double [] min = new double [n];
	final double [] max = new double [n];
	
	for (int i = 0; i< n; i++)
	{
		min[i] = Math.max(0, overlap.realMin(i) - img.realMin(i)) ;
		max[i] = Math.max(0, overlap.realMax(i) - img.realMin(i));
	}
	return new FinalRealInterval(min, max);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:19,代码来源:TransformTools.java


示例8: flatIterable

import net.imglib2.RealInterval; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static final <T extends RealType<T>> IterableRealInterval<T> flatIterable(final RealInterval ri) {
	// If it's any of the known classes that iterates flat, accept as is:
	if ( ArrayImg.class.isInstance( ri )
	  || ListImg.class.isInstance( ri )
	  || IterableRandomAccessibleInterval.class.isInstance(ri)) {
		return (IterableRealInterval<T>) ri;
	}
	// If it's a random accessible, then wrap:
	if ( ri instanceof RandomAccessibleInterval ) {
		return new IterableRandomAccessibleInterval<T>((RandomAccessibleInterval<T>)ri);
	}
	throw new IllegalArgumentException("Don't know how to flat-iterate image " + ri);
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:15,代码来源:Util.java


示例9: Dimensions

import net.imglib2.RealInterval; //导入依赖的package包/类
/**
 * Extract the dimensions of {@param img} multiplied by the {@param factor}.
 * @param img The interval to extract the dimensions of.
 * @param factor The factor to multiply the dimensions.
 */
@SuppressWarnings("boxing")
public Dimensions(final RealInterval img, final Number factor) {
	for (int i=0; i<img.numDimensions(); ++i) {
		add((long)((img.realMax(i) - img.realMin(i) + 1) * factor.doubleValue()));
	}
}
 
开发者ID:imglib,项目名称:imglib2-script,代码行数:12,代码来源:Dimensions.java


示例10: createModel

import net.imglib2.RealInterval; //导入依赖的package包/类
protected Model createModel( final File tgmmFolder, final SpimDataMinimal spimData, final int setupID, final RealInterval interval, final int tFrom, final int tTo )
{

	final SequenceDescriptionMinimal seq = spimData.getSequenceDescription();
	final ViewRegistrations regs = spimData.getViewRegistrations();
	final List< AffineTransform3D > transforms = new ArrayList< AffineTransform3D >( seq.getTimePoints().size() );
	for ( final TimePoint t : seq.getTimePoints().getTimePointsOrdered() )
	{
		transforms.add( regs.getViewRegistration( t.getId(), setupID ).getModel() );
	}

	final TGMMImporter2 importer = new TGMMImporter2( tgmmFolder, transforms, TGMMImporter2.DEFAULT_PATTERN, logger, interval, tFrom, tTo );
	if ( !importer.checkInput() || !importer.process() )
	{
		logger.error( importer.getErrorMessage() );
	}
	final Model model = importer.getResult();

	/*
	 * Hack to set the POSITION_T feature of imported spots.
	 */
	final Settings settings = new Settings();
	settings.dt = 1;
	final TrackMate trackmate = new TrackMate( model, settings );
	final ResetSpotTimeFeatureAction action = new ResetSpotTimeFeatureAction();
	action.execute( trackmate );

	return model;
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:30,代码来源:ImportTGMMAnnotationPlugin_.java


示例11: TGMMImporter2

import net.imglib2.RealInterval; //导入依赖的package包/类
public TGMMImporter2( final File file, final List< AffineTransform3D > transforms, final Pattern framePattern, final Logger logger, final RealInterval interval, final int tFrom, final int tTo )
{
	this.file = file;
	this.framePattern = framePattern;
	this.transforms = transforms;
	this.logger = logger;
	this.interval = interval;
	this.tFrom = tFrom;
	this.tTo = tTo;
}
 
开发者ID:fiji,项目名称:MaMuT,代码行数:11,代码来源:TGMMImporter2.java


示例12: realRandomAccess

import net.imglib2.RealInterval; //导入依赖的package包/类
@Override
public RealRandomAccess<FloatType> realRandomAccess( final RealInterval interval )
{
	return Views.interpolate(
			Views.extendZero( this.contentBasedImg ),
			new NLinearInterpolatorFactory< FloatType >()
			).realRandomAccess( interval );
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:9,代码来源:ContentBased.java


示例13: main

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


示例14: main

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


示例15: printRealInterval

import net.imglib2.RealInterval; //导入依赖的package包/类
public static String printRealInterval( final RealInterval interval )
{
	String out = "(Interval empty)";

	if ( interval == null || interval.numDimensions() == 0 )
		return out;

	out = "[" + interval.realMin( 0 );

	for ( int i = 1; i < interval.numDimensions(); i++ )
		out += ", " + interval.realMin( i );

	out += "] -> [" + interval.realMax( 0 );

	for ( int i = 1; i < interval.numDimensions(); i++ )
		out += ", " + interval.realMax( i );

	out += "]";

	return out;
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:22,代码来源:TransformTools.java


示例16: reCenterViews

import net.imglib2.RealInterval; //导入依赖的package包/类
public static void reCenterViews(final BigDataViewer viewer, final Collection<BasicViewDescription< ? >> selectedViews, final ViewRegistrations viewRegistrations)
{
	AffineTransform3D currentViewerTransform = viewer.getViewer().getDisplay().getTransformEventHandler().getTransform().copy();
	final int cX = viewer.getViewer().getWidth() / 2; // size of the display area of the frame
	final int cY = viewer.getViewer().getHeight() / 2; // size of the display area of the frame

	IOFunctions.println( viewer.getViewer().getWidth() + " " + viewer.getViewer().getHeight() );

	final HashMap< BasicViewDescription< ? >, Dimensions > dimensions = new HashMap<>();
	final HashMap< BasicViewDescription< ? >, AffineTransform3D > registrations = new HashMap<>();

	for ( final BasicViewDescription< ? > view : selectedViews )
	{
		viewRegistrations.getViewRegistration( view ).updateModel();
		registrations.put( view, viewRegistrations.getViewRegistration( view ).getModel() );
		dimensions.put( view, view.getViewSetup().getSize() );
	}

	final BoundingBox bb = new BoundingBoxMaximal( selectedViews, dimensions, registrations ).estimate( "max" );
	final double[] com = new double[] {
			( bb.max( 0 ) - bb.min( 0 ) )/2 + bb.min( 0 ),
			( bb.max( 1 ) - bb.min( 1 ) )/2 + bb.min( 1 ),
			( bb.max( 2 ) - bb.min( 2 ) )/2 + bb.min( 2 ) };

	final RealInterval bounds = currentViewerTransform.estimateBounds( bb );
	IOFunctions.println( TransformTools.printRealInterval( bounds ));

	double currentScale = Math.max( 
			( bounds.realMax( 0 ) - bounds.realMin( 0 ) ) / viewer.getViewer().getWidth(),
			( bounds.realMax( 1 ) - bounds.realMin( 1 ) ) / viewer.getViewer().getHeight() );

	final Scale3D scale = new Scale3D( 1.0/currentScale, 1.0/currentScale, 1.0/currentScale );

	// ignore old translation
	currentViewerTransform.set( 0, 0, 3 );
	currentViewerTransform.set( 0, 1, 3 );
	currentViewerTransform.set( 0, 2, 3 );

	currentViewerTransform.preConcatenate( scale );

	// to screen units
	currentViewerTransform.apply( com, com );

	// reset translational part
	currentViewerTransform.set( -com[0] + cX , 0, 3 );
	currentViewerTransform.set( -com[1] + cY , 1, 3 );

	// check if all selected views are 2d
	boolean allViews2D = true;
	for (final BasicViewDescription< ? > vd : selectedViews)
		if (vd.isPresent() && vd.getViewSetup().hasSize() && vd.getViewSetup().getSize().dimension( 2 ) != 1)
		{
			allViews2D = false;
			break;
		}

	// do not move in z if we have 2d data
	if (allViews2D)
		currentViewerTransform.set( 0, 2, 3 );
	else
		currentViewerTransform.set( -com[2], 2, 3 );

	viewer.getViewer().setCurrentViewerTransform( currentViewerTransform );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:65,代码来源:TransformationTools.java


示例17: computeStitchingNonEqualTransformations

import net.imglib2.RealInterval; //导入依赖的package包/类
public static < T extends RealType< T > > Pair<Pair< AffineGet, Double >, RealInterval> computeStitchingNonEqualTransformations(
		final Group<? extends ViewId> viewIdsA,
		final Group<? extends ViewId> viewIdsB,
		final ViewRegistrations vrs,
		final PairwiseStitchingParameters params,
		final AbstractSequenceDescription< ?,? extends BasicViewDescription<?>, ? > sd,
		final GroupedViewAggregator gva,
		final long[] downsampleFactors,
		final ExecutorService service )
{

	final double[] downsampleDbl = new double[downsampleFactors.length];
	for (int d = 0; d < downsampleFactors.length; d++)
		downsampleDbl[d] = downsampleFactors[d];

	// get Overlap Bounding Box
	final List<List<ViewId>> views = new ArrayList<>();
	views.add( new ArrayList<>(viewIdsA.getViews()) );
	views.add( new ArrayList<>(viewIdsB.getViews()) );
	BoundingBoxMaximalGroupOverlap< ViewId > bbDet = new BoundingBoxMaximalGroupOverlap<ViewId>( views, sd, vrs );
	BoundingBox bbOverlap = bbDet.estimate( "Max Overlap" );

	
	List<RandomAccessibleInterval< FloatType >> raiOverlaps = new ArrayList<>();		
	for (List< ViewId > tileViews : views)
	{
		// wrap every view id (corresponding e.g. to different channels, illums,.. ) in list
		List<List< ViewId >> wrapped = tileViews.stream().map( v -> {
			ArrayList< ViewId > wrp = new ArrayList<ViewId>();
			wrp.add( v );
			return wrp;} ).collect( Collectors.toList() );

		// open all of them "virtually fused"
		List< RandomAccessibleInterval< FloatType > > openFused = 
				DisplayOverlapTestPopup.openVirtuallyFused( sd, vrs, wrapped, bbOverlap, downsampleDbl );

		// aggregate the group into one image
		RandomAccessibleInterval< FloatType > raiI = gva.aggregate( 
				openFused, 
				tileViews,
				sd );

		raiOverlaps.add(raiI);
	}

	// the overlap in both images
	final RandomAccessibleInterval< FloatType > img1 = raiOverlaps.get(0);
	final RandomAccessibleInterval< FloatType > img2 = raiOverlaps.get(1);
	
	// compute phase correlation shift (passing (0,0,..) translations prevents any overlap correction inside)
	final Pair< Translation, Double > result = PairwiseStitching.getShift(
			img1,
			img2,
			new Translation( img1.numDimensions() ),
			new Translation( img1.numDimensions() ),
			params,
			service );

	if (result == null)
		return null;

	for (int i = 0; i< result.getA().numDimensions(); ++i)			
		result.getA().set( result.getA().get(i, result.getA().numDimensions()) * downsampleFactors[i], i ); 

	// TODO (?): Different translational part of downsample Transformations should be considered via TransformTools.getInitialTransforms
	// we probalbly do not have to correct for them ?
	final AffineTransform3D vr = vrs.getViewRegistration(viewIdsB.iterator().next()).getModel();		
	final AffineTransform resCorrected = new AffineTransform( result.getA().numDimensions() );
	resCorrected.set( result.getA() );

	System.out.println("shift: " + Util.printCoordinates(result.getA().getTranslationCopy()));
	System.out.print("cross-corr: " + result.getB());

	return new ValuePair<>( new ValuePair<>( resCorrected, result.getB() ), bbOverlap );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:76,代码来源:TransformationTools.java


示例18: computeStitchingNonEqualTransformationsLucasKanade

import net.imglib2.RealInterval; //导入依赖的package包/类
public static < T extends RealType< T > > Pair<Pair< AffineGet, Double >, RealInterval> computeStitchingNonEqualTransformationsLucasKanade(
		final Group<? extends ViewId> viewIdsA,
		final Group<? extends ViewId> viewIdsB,
		final ViewRegistrations vrs,
		final LucasKanadeParameters params,
		final AbstractSequenceDescription< ?,? extends BasicViewDescription<?>, ? > sd,
		final GroupedViewAggregator gva,
		final long[] downsampleFactors,
		final ExecutorService service )
{
	final double[] downsampleDbl = new double[downsampleFactors.length];
	for (int d = 0; d < downsampleFactors.length; d++)
		downsampleDbl[d] = downsampleFactors[d];

	// get Overlap Bounding Box
	final List<List<ViewId>> views = new ArrayList<>();
	views.add( new ArrayList<>(viewIdsA.getViews()) );
	views.add( new ArrayList<>(viewIdsB.getViews()) );
	BoundingBoxMaximalGroupOverlap< ViewId > bbDet = new BoundingBoxMaximalGroupOverlap<ViewId>( views, sd, vrs );
	BoundingBox bbOverlap = bbDet.estimate( "Max Overlap" );

	
	List<RandomAccessibleInterval< FloatType >> raiOverlaps = new ArrayList<>();		
	for (List< ViewId > tileViews : views)
	{
		// wrap every view id (corresponding e.g. to different channels, illums,.. ) in list
		List<List< ViewId >> wrapped = tileViews.stream().map( v -> {
			ArrayList< ViewId > wrp = new ArrayList<ViewId>();
			wrp.add( v );
			return wrp;} ).collect( Collectors.toList() );

		// open all of them "virtually fused"
		List< RandomAccessibleInterval< FloatType > > openFused = 
				DisplayOverlapTestPopup.openVirtuallyFused( sd, vrs, wrapped, bbOverlap, downsampleDbl );

		// aggregate the group into one image
		RandomAccessibleInterval< FloatType > raiI = gva.aggregate( 
				openFused, 
				tileViews,
				sd );

		raiOverlaps.add(raiI);
	}

	// the overlap in both images
	final RandomAccessibleInterval< FloatType > img1 = raiOverlaps.get(0);
	final RandomAccessibleInterval< FloatType > img2 = raiOverlaps.get(1);
	
	// compute phase correlation shift (passing (0,0,..) translations prevents any overlap correction inside)
	final Pair< AffineTransform, Double > result = PairwiseStitching.getShiftLucasKanade(
			img1,
			img2,
			new Translation( img1.numDimensions() ),
			new Translation( img1.numDimensions() ),
			params,
			service );

	if (result == null)
		return null;

	// scale just the translational part
	for (int i = 0; i< result.getA().numDimensions(); ++i)			
		result.getA().set( result.getA().get(i, result.getA().numDimensions()) * downsampleFactors[i], i ); 

	// TODO (?): Different translational part of downsample Transformations should be considered via TransformTools.getInitialTransforms
	// we probalbly do not have to correct for them ?

	final AffineTransform3D vr = vrs.getViewRegistration(viewIdsB.iterator().next()).getModel();		
	final AffineTransform resCorrected = new AffineTransform( result.getA().numDimensions() );
	resCorrected.set( result.getA() );

	IOFunctions.println("resulting transformation: " + Util.printCoordinates(result.getA().getRowPackedCopy()));

	return new ValuePair<>( new ValuePair<>( resCorrected, result.getB() ), bbOverlap );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:76,代码来源:TransformationTools.java


示例19: computeStitching

import net.imglib2.RealInterval; //导入依赖的package包/类
public static < T extends RealType< T > > Pair<Pair< AffineGet, Double >, RealInterval> computeStitching(
		final Group<? extends ViewId> viewIdsA,
		final Group<? extends ViewId> viewIdsB,
		final ViewRegistrations vrs,
		final PairwiseStitchingParameters params,
		final AbstractSequenceDescription< ?,? extends BasicViewDescription<?>, ? > sd,
		final GroupedViewAggregator gva,
		final long[] downsampleFactors,
		final ExecutorService service )
{
	
	// the transformation that maps the downsampled image coordinates back to the original input(!) image space
	final AffineTransform3D dsCorrectionT1 = new AffineTransform3D();
	final AffineTransform3D dsCorrectionT2 = new AffineTransform3D();

	// get Overlap Bounding Box
	final List<List<ViewId>> views = new ArrayList<>();
	views.add( new ArrayList<>(viewIdsA.getViews()) );
	views.add( new ArrayList<>(viewIdsB.getViews()) );
	BoundingBoxMaximalGroupOverlap< ViewId > bbDet = new BoundingBoxMaximalGroupOverlap<ViewId>( views, sd, vrs );
	BoundingBox bbOverlap = bbDet.estimate( "Max Overlap" );

	// this should be caught outside of this method already, but check nonetheless
	if (bbOverlap == null)
		return null;

	// get one image per group
	final RandomAccessibleInterval<T> img1 = gva.aggregate( viewIdsA, sd, downsampleFactors, dsCorrectionT1 );	
	final RandomAccessibleInterval<T> img2 = gva.aggregate( viewIdsB, sd, downsampleFactors, dsCorrectionT2 );

	if (img1 == null || img2 == null)
	{
		IOFunctions.println( "WARNING: Tried to open missing View when computing Stitching for " + viewIdsA + " and " + 
					viewIdsB + ". No link between those could be determined");
		return null;
	}

	// get translations
	// TODO: is the 2d check here meaningful?
	// everything will probably be 3d at this point, since ImgLoaders return 3d images
	boolean is2d = img1.numDimensions() == 2;
	Pair< AffineGet, TranslationGet > t1 = TransformTools.getInitialTransforms( vrs.getViewRegistration(viewIdsA.iterator().next()), is2d, dsCorrectionT1 );
	Pair< AffineGet, TranslationGet > t2 = TransformTools.getInitialTransforms( vrs.getViewRegistration(viewIdsB.iterator().next()), is2d, dsCorrectionT2 );

	final Pair< Translation, Double > result  = PairwiseStitching.getShift( img1, img2, t1.getB(), t2.getB(), params, service );

	if (result == null)
		return null;
	
	for (int i = 0; i< result.getA().numDimensions(); ++i)			
		result.getA().set( result.getA().get(i, result.getA().numDimensions()) * downsampleFactors[i], i ); 

	// TODO (?): Different translational part of downsample Transformations should be considered via TransformTools.getInitialTransforms
	// we probalbly do not have to correct for them ?

	// NB: as we will deal in global coordinates, not pixel coordinates in global optimization,
	// calculate global R' = VT^-1 * R * VT from pixel transformation R 
	ViewRegistration vrOld = vrs.getViewRegistration(viewIdsB.iterator().next());
	AffineTransform3D resTransform = new AffineTransform3D();
	resTransform.set( result.getA().getRowPackedCopy() );
	resTransform.concatenate( vrOld.getModel().inverse() );
	resTransform.preConcatenate( vrOld.getModel() );

	System.out.println("shift (pixel coordinates): " + Util.printCoordinates(result.getA().getTranslationCopy()));
	System.out.println("shift (global coordinates): " + Util.printCoordinates(resTransform.getRowPackedCopy()));
	System.out.print("cross-corr: " + result.getB());

	return new ValuePair<>( new ValuePair<>( resTransform, result.getB() ), bbOverlap );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:70,代码来源:TransformationTools.java


示例20: computeStitchingLucasKanade

import net.imglib2.RealInterval; //导入依赖的package包/类
public static < T extends RealType< T > > Pair<Pair< AffineGet, Double >, RealInterval> computeStitchingLucasKanade(
		final Group<? extends ViewId> viewIdsA,
		final Group<? extends ViewId> viewIdsB,
		final ViewRegistrations vrs,
		final LucasKanadeParameters params,
		final AbstractSequenceDescription< ?,? extends BasicViewDescription<?>, ? > sd,
		final GroupedViewAggregator gva,
		final long[] downsampleFactors,
		final ExecutorService service )
{
	
	// the transformation that maps the downsampled image coordinates back to the original input(!) image space
	final AffineTransform3D dsCorrectionT1 = new AffineTransform3D();
	final AffineTransform3D dsCorrectionT2 = new AffineTransform3D();

	// get Overlap Bounding Box
	final List<List<ViewId>> views = new ArrayList<>();
	views.add( new ArrayList<>(viewIdsA.getViews()) );
	views.add( new ArrayList<>(viewIdsB.getViews()) );
	BoundingBoxMaximalGroupOverlap< ViewId > bbDet = new BoundingBoxMaximalGroupOverlap<ViewId>( views, sd, vrs );
	BoundingBox bbOverlap = bbDet.estimate( "Max Overlap" );

	// this should be caught outside of this method already, but check nonetheless
	if (bbOverlap == null)
		return null;

	// get one image per group
	final RandomAccessibleInterval<T> img1 = gva.aggregate( viewIdsA, sd, downsampleFactors, dsCorrectionT1 );	
	final RandomAccessibleInterval<T> img2 = gva.aggregate( viewIdsB, sd, downsampleFactors, dsCorrectionT2 );

	if (img1 == null || img2 == null)
	{
		IOFunctions.println( "WARNING: Tried to open missing View when computing Stitching for " + viewIdsA + " and " + 
					viewIdsB + ". No link between those could be determined");
		return null;
	}

	// get translations
	// TODO: is the 2d check here meaningful?
	boolean is2d = img1.numDimensions() == 2;
	Pair< AffineGet, TranslationGet > t1 = TransformTools.getInitialTransforms( vrs.getViewRegistration(viewIdsA.iterator().next()), is2d, dsCorrectionT1 );
	Pair< AffineGet, TranslationGet > t2 = TransformTools.getInitialTransforms( vrs.getViewRegistration(viewIdsB.iterator().next()), is2d, dsCorrectionT2 );

	final Pair< AffineTransform, Double > result  = PairwiseStitching.getShiftLucasKanade(  img1, img2, t1.getB(), t2.getB(), params, service );

	if (result == null)
		return null;

	// TODO: is scaling just the translational part okay here?
	for (int i = 0; i< result.getA().numDimensions(); ++i)			
		result.getA().set( result.getA().get(i, result.getA().numDimensions()) * downsampleFactors[i], i, result.getA().numDimensions() ); 

	// TODO (?): Different translational part of downsample Transformations should be considered via TransformTools.getInitialTransforms
	// we probalbly do not have to correct for them ?

	// NB: as we will deal in global coordinates, not pixel coordinates in global optimization,
	// calculate global R' = VT^-1 * R * VT from pixel transformation R 
	ViewRegistration vrOld = vrs.getViewRegistration(viewIdsB.iterator().next());
	AffineTransform3D resTransform = new AffineTransform3D();
	resTransform.set( result.getA().getRowPackedCopy() );
	resTransform.concatenate( vrOld.getModel().inverse() );
	resTransform.preConcatenate( vrOld.getModel() );

	IOFunctions.println("resulting transformation (pixel coordinates): " + Util.printCoordinates(result.getA().getRowPackedCopy()));
	IOFunctions.println("resulting transformation (global coordinates): " + Util.printCoordinates(resTransform.getRowPackedCopy()));

	return new ValuePair<>( new ValuePair<>( resTransform, result.getB() ), bbOverlap );
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:69,代码来源:TransformationTools.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MenuPresenter类代码示例发布时间:2022-05-22
下一篇:
Java LoadContext类代码示例发布时间: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