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


Java AffineTransform3D.preConcatenate方法代码示例

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


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

示例1: get

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public AffineTransform3D get( final double t )
{
	final AffineTransform3D transform = new AffineTransform3D();
	transform.set( transformStart );

	// center shift
	transform.set( transform.get( 0, 3 ) - cX, 0, 3 );
	transform.set( transform.get( 1, 3 ) - cY, 1, 3 );

	// rotate
	final AffineTransform3D tAddCurrent = Rotation2DHelpers.rotationToTransform( totalAngle * t );
	transform.preConcatenate( tAddCurrent );

	// center un-shift
	transform.set( transform.get( 0, 3 ) + cX, 0, 3 );
	transform.set( transform.get( 1, 3 ) + cY, 1, 3 );
	

	return transform;
}
 
开发者ID:saalfeldlab,项目名称:bigwarp,代码行数:22,代码来源:RotationAnimator2D.java

示例2: getTile

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public void getTile( final AffineTransform3D viewTransform, final int t, final int tileW, final int tileH, final double screenScale, final Interpolation interpolation, final OutputStream os ) throws IOException
{
	final AffineTransform3D screenScaleTransform = new AffineTransform3D();
	screenScaleTransform.set( screenScale, 0, 0 );
	screenScaleTransform.set( screenScale, 1, 1 );
	screenScaleTransform.set( 0.5 * screenScale - 0.5, 0, 3 );
	screenScaleTransform.set( 0.5 * screenScale - 0.5, 1, 3 );
	viewTransform.preConcatenate( screenScaleTransform );

	state.setViewerTransform( viewTransform );
	state.setCurrentTimepoint( t );
	state.setInterpolation( interpolation );
	renderer.paint( state, ( int ) ( screenScale * tileW ), ( int ) ( screenScale * tileH ) );

	final ImageOutputStream ios = ImageIO.createImageOutputStream( os );
	jpegWriter.setOutput( ios );
	jpegWriter.write( null, new IIOImage( renderer.getBufferedImage(), null, null ), param );
	ios.close();
}
 
开发者ID:tpietzsch,项目名称:TileServer,代码行数:20,代码来源:TileGenerator.java

示例3: drawOverlays

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void drawOverlays( final Graphics g )
{
	final Graphics2D graphics = ( Graphics2D ) g;
	final int t = viewer.getState().getCurrentTimepoint();
	final double[] lPos = new double[ 3 ];
	final double[] gPos = new double[ 3 ];
	final AffineTransform3D transform = new AffineTransform3D();

	for ( final InterestPointSource pointSource : interestPointSources )
	{
		pointSource.getLocalToGlobalTransform( t, transform );
		transform.preConcatenate( viewerTransform );

		for ( final RealLocalizable p : pointSource.getLocalCoordinates( t ) )
		{
			p.localize( lPos );
			transform.apply( lPos, gPos );
			final double size = getPointSize( gPos );
			final int x = ( int ) ( gPos[ 0 ] - 0.5 * size );
			final int y = ( int ) ( gPos[ 1 ] - 0.5 * size );
			final int w = ( int ) size;
			graphics.setColor( getColor( gPos ) );
			graphics.fillOval( x, y, w, w );
		}
	}
}
 
开发者ID:fiji,项目名称:SPIM_Registration,代码行数:28,代码来源:InterestPointOverlay.java

示例4: getTransformedSource

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

示例5: reCenterViews

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

示例6: computeStitching

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

示例7: computeStitchingLucasKanade

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

示例8: main

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void main(String[] args)
	{
		final AffineTransform3D m = new AffineTransform3D();
		double scale = 200;
		m.set( scale, 0.0f, 0.0f, 0.0f, 0.0f, scale, 0.0f, 0.0f, 0.0f, 0.0f, scale, 0.0f );

		final AffineTransform3D mShift = new AffineTransform3D();
		double shift = 100;
		mShift.set( 1.0f, 0.0f, 0.0f, shift, 0.0f, 1.0f, 0.0f, shift, 0.0f, 0.0f, 1.0f, shift );
		final AffineTransform3D mShift2 = new AffineTransform3D();
		double shift2x = 1200;
		double shift2y = 300;
		mShift2.set( 1.0f, 0.0f, 0.0f, shift2x, 0.0f, 1.0f, 0.0f, shift2y, 0.0f, 0.0f, 1.0f, 0.0f );

		final AffineTransform3D mShift3 = new AffineTransform3D();
		double shift3x = 500;
		double shift3y = 1300;
		mShift3.set( 1.0f, 0.0f, 0.0f, shift3x, 0.0f, 1.0f, 0.0f, shift3y, 0.0f, 0.0f, 1.0f, 0.0f );

		AffineTransform3D m2 = m.copy();
		AffineTransform3D m3 = m.copy();
		m.preConcatenate( mShift );
		m2.preConcatenate( mShift2 );
		m3.preConcatenate( mShift3 );

		Interval start = new FinalInterval( new long[] { -399, -399, 0 }, new long[] { 0, 0, 1 } );
		List< Interval > intervals = FractalSpimDataGenerator.generateTileList( start, 7, 6, 0.2f );

		List< Interval > falseStarts = FractalSpimDataGenerator.generateTileList( start, 7, 6, 0.30f );

		FractalSpimDataGenerator fsdg = new FractalSpimDataGenerator( 3 );
		fsdg.addFractal( m );
		fsdg.addFractal( m2 );
		fsdg.addFractal( m3 );

		Map< Integer, RandomAccessibleInterval< LongType > > rais = new HashMap< >();
		Map< Integer, TranslationGet > tr = new HashMap< >();

		List< TranslationGet > tileTranslations = FractalSpimDataGenerator.getTileTranslations( falseStarts );

		FractalImgLoader imgLoader = (FractalImgLoader) fsdg.generateSpimData( intervals ).getSequenceDescription()
				.getImgLoader();
		for ( int i = 0; i < intervals.size(); i++ )
		{
			rais.put( i, imgLoader.getImageAtInterval( intervals.get( i ) ) );
			tr.put( i, tileTranslations.get( i ) );
		}

		List< PairwiseStitchingResult< Integer > > pairwiseShifts = getPairwiseShifts( rais, tr,
				new PairwiseStitchingParameters(),
				Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors() ) );

		
		Map< Integer, AffineGet > collect = tr.entrySet().stream().collect( Collectors.toMap( e -> 
			e.getKey(), e -> {AffineTransform3D res = new AffineTransform3D(); res.set( e.getValue().getRowPackedCopy() ); return res; } ));
		
		// TODO: replace with new globalOpt code
		
//		Map< Set<Integer>, AffineGet > globalOptimization = GlobalTileOptimization.twoRoundGlobalOptimization( new TranslationModel3D(),
//				rais.keySet().stream().map( ( c ) -> {Set<Integer> s = new HashSet<>(); s.add( c ); return s;}).collect( Collectors.toList() ), 
//				null, 
//				collect,
//				pairwiseShifts, new GlobalOptimizationParameters() );
//
//		System.out.println( globalOptimization );
	}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:67,代码来源:PairwiseStitching.java

示例9: createVirtualSpimData

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static SpimData2 createVirtualSpimData()
{
	// shift and scale the fractal
	final AffineTransform3D m = new AffineTransform3D();
	double scale = 200;
	m.set( scale, 0.0f, 0.0f, 0.0f, 
		   0.0f, scale, 0.0f, 0.0f,
		   0.0f, 0.0f, scale, 0.0f);
	
	final AffineTransform3D mShift = new AffineTransform3D();
	double shift = 100;
	mShift.set( 1.0f, 0.0f, 0.0f, shift, 
				0.0f, 1.0f, 0.0f, shift,
				0.0f, 0.0f, 1.0f, shift
				);
	final AffineTransform3D mShift2 = new AffineTransform3D();
	double shift2x = 1200;
	double shift2y = 300;
	mShift2.set( 1.0f, 0.0f, 0.0f, shift2x, 
				0.0f, 1.0f, 0.0f, shift2y,
				0.0f, 0.0f, 1.0f, 0.0f
				);
	
	final AffineTransform3D mShift3 = new AffineTransform3D();
	double shift3x = 500;
	double shift3y = 1300;
	mShift3.set( 1.0f, 0.0f, 0.0f, shift3x, 
				0.0f, 1.0f, 0.0f, shift3y,
				0.0f, 0.0f, 1.0f, 0.0f
				);
	
	
	AffineTransform3D m2 = m.copy();
	AffineTransform3D m3 = m.copy();
	m.preConcatenate( mShift );
	m2.preConcatenate( mShift2 );
	m3.preConcatenate( mShift3 );
	
	final int tilesX = 7;
	final int tilesY = 6;
	m.preConcatenate( new Translation3D( -300, 0, 0 ) );

	final float correctOverlap = 0.2f;
	final float wrongOverlap = 0.3f;

	Interval start = new FinalInterval( new long[] {-399,-399,0},  new long[] {0, 0, 0});
	List<Interval> intervals = FractalSpimDataGenerator.generateTileList( 
			start, tilesX, tilesY, correctOverlap );
	
	List<RealLocalizable> falseStarts = FractalSpimDataGenerator.getTileMins(
													FractalSpimDataGenerator.generateTileList( start, tilesX, tilesY, wrongOverlap ));
	
	FractalSpimDataGenerator fsdg = new FractalSpimDataGenerator( 3 );
	fsdg.addFractal( m );
	fsdg.addFractal( m2 );
	fsdg.addFractal( m3 );
	
	return fsdg.generateSpimData( intervals , falseStarts);
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:60,代码来源:FractalSpimDataGenerator.java

示例10: updateBDV

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
private void updateBDV()
{

	BigDataViewer bdv = parent.bdvPopup().getBDV();
	if ( bdv != null )

	{
		
		//FilteredAndGroupedExplorerPanel.resetBDVManualTransformations( bdv );

		RegularTranslationParameters params = new RegularTranslationParameters();
		params.nDimensions = 3;
		params.alternating = alternating;
		params.dimensionOrder = dimensionOrder;
		params.increasing = increasing;
		params.overlaps = overlaps;
		params.nSteps = steps;
		params.keepRotation = rotate;

		Dimensions size = parent.getSpimData().getSequenceDescription().getViewDescriptions()
				.get( selectedVDs.get( 0 ).get( 0 ) ).getViewSetup().getSize();
		List< Translation3D > generateRegularGrid = RegularTranformHelpers.generateRegularGrid( params, size );
		int i = 0;
		for ( List< BasicViewDescription< ? > > lvd : selectedVDs )
		{

			// we did not generate enough transformations
			// -> leave the rest of the views as-is
			if (i>generateRegularGrid.size())
				break;

			for ( BasicViewDescription< ? > vd : lvd )
			{
				
				int sourceIdx = StitchingExplorerPanel.getBDVSourceIndex( vd.getViewSetup(), parent.getSpimData() );
				SourceState< ? > s = parent.bdvPopup().getBDV().getViewer().getState().getSources().get( sourceIdx );
				

				ViewRegistration vr = parent.getSpimData().getViewRegistrations().getViewRegistration( vd );
				AffineTransform3D inv = vr.getModel().copy().inverse();
				AffineTransform3D calib = new AffineTransform3D();
				calib.set( vr.getTransformList().get( vr.getTransformList().size() - 1 ).asAffine3D().getRowPackedCopy() );

				//invAndCalib.preConcatenate( vr.getTransformList().get( 0 ).asAffine3D() );

				AffineTransform3D grid = new AffineTransform3D();
				if (i < generateRegularGrid.size())
					grid.set( generateRegularGrid.get( i ).getRowPackedCopy() );

				AffineTransform3D gridTransform = ( i < generateRegularGrid.size() )
						? inv.preConcatenate( grid.copy() ) : inv.copy();

				gridTransform.preConcatenate( calib );

				if (rotate)
				{
					AffineTransform3D rotation = new AffineTransform3D();
					Pair< Double, Integer > rotAngleAndAxis = RegularTranformHelpers.getRoatationFromMetadata( vd.getViewSetup().getAttribute( Angle.class ) );
					if (rotAngleAndAxis != null)
					{
						rotation.rotate( rotAngleAndAxis.getB(), rotAngleAndAxis.getA() );
						gridTransform.preConcatenate( rotation.copy() );
					}
				}

				( (TransformedSource< ? >) s.getSpimSource() ).setFixedTransform( gridTransform );

			}
			i++;
		}

		
		bdv.getViewer().requestRepaint();

	}

}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:78,代码来源:PreviewRegularGridPanel.java

示例11: drawOverlays

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void drawOverlays(Graphics g)
{
	// dont do anything if the overlay was set to inactive or we have no Tile selected (no links to display)
	if (!isActive || activeLinks.size() == 0)
		return;

	for ( Pair<Group<ViewId>, Group<ViewId>> p: activeLinks)
	{
		// local coordinates of views, without BDV transform 
		final double[] lPos1 = new double[ 3 ];
		final double[] lPos2 = new double[ 3 ];
		// global coordianates, after BDV transform
		final double[] gPos1 = new double[ 3 ];
		final double[] gPos2 = new double[ 3 ];
		
		BasicViewDescription<?> vdA = spimData.getSequenceDescription().getViewDescriptions().get( p.getA().iterator().next() );
		BasicViewDescription<?> vdB = spimData.getSequenceDescription().getViewDescriptions().get( p.getB().iterator().next() );
		ViewRegistration vrA = spimData.getViewRegistrations().getViewRegistration(  p.getA().iterator().next() );
		ViewRegistration vrB = spimData.getViewRegistrations().getViewRegistration(  p.getB().iterator().next() );

		long[] sizeA = new long[vdA.getViewSetup().getSize().numDimensions()];
		long[] sizeB = new long[vdB.getViewSetup().getSize().numDimensions()];
		spimData.getSequenceDescription().getViewDescriptions().get( p.getA().iterator().next() ).getViewSetup().getSize().dimensions( sizeA );
		spimData.getSequenceDescription().getViewDescriptions().get( p.getB().iterator().next() ).getViewSetup().getSize().dimensions( sizeB );
		
		// TODO: this uses the transform of the first view in the set, maybe do something better?
		AffineTransform3D vt1 = spimData.getViewRegistrations().getViewRegistration( p.getA().iterator().next() ).getModel();
		AffineTransform3D vt2 = spimData.getViewRegistrations().getViewRegistration( p.getB().iterator().next() ).getModel();
		
		boolean overlaps = SimpleBoundingBoxOverlap.overlaps( SimpleBoundingBoxOverlap.getBoundingBox(	vdA.getViewSetup(), vrA ), SimpleBoundingBoxOverlap.getBoundingBox( vdB.getViewSetup(), vrB ) );

		if (!overlaps)
			continue;
		
		final AffineTransform3D transform = new AffineTransform3D();
		transform.preConcatenate( viewerTransform );

		for( int i = 0; i < 3; i++)
		{
			// start from middle of view
			lPos1[i] += sizeA[i] / 2;
			lPos2[i] += sizeB[i] / 2;
		}

		vt1.apply( lPos1, lPos1 );
		vt2.apply( lPos2, lPos2 );
		
		transform.apply( lPos1, gPos1 );
		transform.apply( lPos2, gPos2 );

		Graphics2D g2d = null;

		if ( Graphics2D.class.isInstance( g ) )
			g2d = (Graphics2D) g;

		if ( lastFilteredResults.contains( p ) || lastFilteredResults.contains( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.ORANGE );
			if ( g2d != null ) g2d.setStroke( dashed );
		}
		else if ( lastInconsistentResults.contains( p ) || lastInconsistentResults.contains( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.RED );
			if ( g2d != null ) g2d.setStroke( dashed );
		}
		else if ( stitchingResults.getPairwiseResults().containsKey( p ) || stitchingResults.getPairwiseResults().containsKey( TransformationTools.reversePair( p ) ) )
		{
			g.setColor( Color.GREEN );
			if ( g2d != null ) g2d.setStroke( thick );
		}
		else
		{
			g.setColor( Color.GRAY );
			if ( g2d != null ) g2d.setStroke( dashed );
		}

		g.drawLine((int) gPos1[0],(int) gPos1[1],(int) gPos2[0],(int) gPos2[1] );
	}
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:81,代码来源:DemoLinkOverlay.java

示例12: updateBDVPreview

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void updateBDVPreview(Map<ViewId, Translation3D> locations, boolean pixelUnits, boolean keepRotation,
		AbstractSpimData< ? > data, BigDataViewer bdv)
{
	if (data == null || bdv == null )
		return;

	final Map< ViewId, Translation3D > transformsForData = getTransformsForData( locations, pixelUnits, data );
	final Collection< BasicViewDescription< ? > > vds = (Collection< BasicViewDescription< ? > >) data.getSequenceDescription().getViewDescriptions().values();
	final int currentTPId = data.getSequenceDescription().getTimePoints().getTimePointsOrdered()
			.get( bdv.getViewer().getState().getCurrentTimepoint() ).getId();
	for ( BasicViewDescription< ? > vd : vds )
	{
		if (vd.getTimePointId() != currentTPId)
			continue;

		final int sourceIdx = StitchingExplorerPanel.getBDVSourceIndex( vd.getViewSetup(), data );
		final SourceState< ? > s = bdv.getViewer().getState().getSources().get( sourceIdx );

		final ViewRegistration vr = data.getViewRegistrations().getViewRegistration( vd );
		final AffineTransform3D inv = vr.getModel().copy().inverse();
		
		final AffineTransform3D calib = new AffineTransform3D();
		calib.set( vr.getTransformList().get( vr.getTransformList().size() - 1 ).asAffine3D().getRowPackedCopy() );

		AffineTransform3D transform;
		if (transformsForData.containsKey( vd ))
		{
			transform  = inv.copy().preConcatenate( calib ).preConcatenate( transformsForData.get( vd ) );
		}
		else
			continue;

		if (keepRotation)
		{
			AffineTransform3D rotation = new AffineTransform3D();
			Pair< Double, Integer > rotAngleAndAxis = RegularTranformHelpers.getRoatationFromMetadata( vd.getViewSetup().getAttribute( Angle.class ) );
			if (rotAngleAndAxis != null)
			{
				rotation.rotate( rotAngleAndAxis.getB(), rotAngleAndAxis.getA() );
				transform.preConcatenate( rotation.copy() );
			}
		}

		( (TransformedSource< ? >) s.getSpimSource() ).setFixedTransform( transform );
	}

	bdv.getViewer().requestRepaint();
}
 
开发者ID:PreibischLab,项目名称:BigStitcher,代码行数:49,代码来源:TileConfigurationHelpers.java

示例13: click

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
@Override
public void click( final int x, final int y )
{
	synchronized ( viewer )
	{
		if ( idPicker.getIdAtDisplayCoordinate( x, y ) == Label.OUTSIDE )
			return;
		final AffineTransform3D transform = new AffineTransform3D();
		viewer.getState().getViewerTransform( transform );
		final double scale = Affine3DHelpers.extractScale( transform, 0 ) * minLabelScale / Math.sqrt( 3 );
		System.out.println( labelTransform );
		final int xScale = ( int ) Math.round( x / scale );
		final int yScale = ( int ) Math.round( y / scale );
		final long[] initialMin = { xScale - 16, yScale - 16 };
		final long[] initialMax = { xScale + 15, yScale + 15 };
		viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
		setCoordinates( x, y );
		System.out.println( "Filling " + labelLocation + " with " + selectionController.getActiveFragmentId() + " (2D)" );

		final RealPoint rp = new RealPoint( 3 );
		transform.apply( labelLocation, rp );
		final Point p = new Point( xScale, yScale );

		System.out.println( x + " " + y + " " + p + " " + rp );

		final AffineTransform3D tf = labelTransform.copy();
		tf.preConcatenate( transform );
		tf.preConcatenate( new Scale3D( 1.0 / scale, 1.0 / scale, 1.0 / scale ) );

		final AffineTransform3D tfFront = tf.copy().preConcatenate( new Translation3D( 0, 0, -1.0 / Math.sqrt( 3 ) ) );
		final AffineTransform3D tfBack = tf.copy().preConcatenate( new Translation3D( 0, 0, 1.0 / Math.sqrt( 3 ) ) );

		final long t0 = System.currentTimeMillis();

		final BitType notVisited = new BitType( false );
		final BitType fillLabel = new BitType( true );

		final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFillFront = fillMask( tfFront, initialMin, initialMax, p, notVisited.copy(), fillLabel.copy() );
		final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFillBack = fillMask( tfBack, initialMin, initialMax, p, notVisited.copy(), fillLabel.copy() );

		final long label = selectionController.getActiveFragmentId();

		writeMask( tmpFillFront, tfFront, label );
		writeMask( tmpFillBack, tfBack, label );

		final long t1 = System.currentTimeMillis();
		System.out.println( "Filling took " + ( t1 - t0 ) + " ms" );
		System.out.println( "  modified box: " + Util.printInterval( dirtyLabelsInterval.getDirtyInterval() ) );
		viewer.setCursor( Cursor.getPredefinedCursor( Cursor.DEFAULT_CURSOR ) );
		viewer.requestRepaint();

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

示例14: main

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
final static public void main( final String[] args )
		throws ImgIOException
	{
		new ImageJ();

		final ImgOpener io = new ImgOpener();
		//final RandomAccessibleInterval< UnsignedShortType > img = io.openImg( "/home/saalfeld/phd/light-microscopy/presentation/saalfeld-05-05-4-DPX-05_L1_Sum.lsm", new ArrayImgFactory< UnsignedShortType >(), new UnsignedShortType());
		final ImgPlus< UnsignedShortType > imgPlus = io.openImg( "/home/saalfeld/Desktop/l1-cns.tif", new ArrayImgFactory< UnsignedShortType >(), new UnsignedShortType());

		// TODO - using averageScale() introduces error for nonlinear axes
		final double scale0 = imgPlus.averageScale(0);
		final double scale1 = imgPlus.averageScale(1);
		final double[][] matrix = new double[][]{
				{ 0.5, 0, 0, imgPlus.dimension( 0 ) * 0.25 },
				{ 0, 0.5 * scale1 / scale0, 0, imgPlus.dimension(1) * 0.25 },
				// TODO - this scale code is how it was before average() code
				// added. Might be a bug. Review.
				{ 0, 0, 0.5 * scale0 / scale0, 0 }
		};
//		final AffineTransform affine = new AffineTransform( new Matrix( matrix ) );
		final AffineTransform3D affine = new AffineTransform3D();
		affine.set( matrix[ 0 ][ 0 ], matrix[ 0 ][ 1 ], matrix[ 0 ][ 2 ], matrix[ 0 ][ 3 ], matrix[ 1 ][ 0 ], matrix[ 1 ][ 1 ], matrix[ 1 ][ 2 ], matrix[ 1 ][ 3 ], matrix[ 2 ][ 0 ], matrix[ 2 ][ 1 ], matrix[ 2 ][ 2 ], matrix[ 2 ][ 3 ] );

//		final InterpolatorFactory< UnsignedShortType, RandomAccessible< UnsignedShortType > > interpolatorFactory = new NearestNeighborInterpolatorFactory< UnsignedShortType >();
//		final InterpolatorFactory< UnsignedShortType, RandomAccessible< UnsignedShortType > > interpolatorFactory = new NLinearInterpolatorFactory< UnsignedShortType >();
		final InterpolatorFactory< UnsignedShortType, RandomAccessible< UnsignedShortType > > interpolatorFactory = new LanczosInterpolatorFactory< UnsignedShortType >();

		final RandomAccessible< UnsignedShortType > extendedImg = Views.extendValue( imgPlus, new UnsignedShortType() );
		final Interpolant< UnsignedShortType, RandomAccessible< UnsignedShortType > > interpolant = new Interpolant< UnsignedShortType, RandomAccessible< UnsignedShortType > >( extendedImg, interpolatorFactory );
		final AffineRandomAccessible< UnsignedShortType, AffineGet > mapping = new AffineRandomAccessible< UnsignedShortType, AffineGet >( interpolant, affine );

		final ARGBScreenImage screenImage = new ARGBScreenImage( ( int )imgPlus.dimension( 0 ), ( int )imgPlus.dimension( 1 ) );
		final IterableIntervalProjector2D< UnsignedShortType, ARGBType > projector = new IterableIntervalProjector2D< UnsignedShortType, ARGBType >( 0, 1, mapping, screenImage, new RealARGBConverter< UnsignedShortType >( 0, 4095 ) );

		final ColorProcessor cp = new ColorProcessor( screenImage.image() );
		final ImagePlus imp = new ImagePlus( "argbScreenProjection", cp );
		imp.show();

		final Timer timer = new Timer();

		projector.setPosition( imgPlus.dimension( 2 ) / 2, 2 );

		final AffineTransform3D forward = new AffineTransform3D();
		final AffineTransform3D rotation = new AffineTransform3D();
		final AffineTransform3D scale = new AffineTransform3D();
		scale.set(
				4, 0, 0, 0,
				0, 4, 0, 0,
				0, 0, 4, 0 );

		for ( int k = 0; k < 3; ++k )
		{
			timer.start();
			for ( int i = 45; i < 48; ++i )
			{
				rotation.rotate( 1, Math.PI / 360 );
				forward.set(
						1.0, 0, 0, -imgPlus.dimension( 0 ) / 2.0,
						0, 1.0, 0, -imgPlus.dimension( 1 ) / 2.0,
						0, 0, 1.0, -imgPlus.dimension( 2 ) / 2.0 );
				forward.preConcatenate( scale );
				forward.preConcatenate( rotation );
				forward.set(
						forward.get( 0, 0 ), forward.get( 0, 1 ), forward.get( 0, 2 ), forward.get( 0, 3 ) + imgPlus.dimension( 0 ) / 2.0,
						forward.get( 1, 0 ), forward.get( 1, 1 ), forward.get( 1, 2 ), forward.get( 1, 3 ) + imgPlus.dimension( 1 ) / 2.0,
						forward.get( 2, 0 ), forward.get( 2, 1 ), forward.get( 2, 2 ), forward.get( 2, 3 ) + imgPlus.dimension( 2 ) / 2.0 );

				affine.set( forward.inverse() );

				projector.map();

				imp.setImage( screenImage.image() );
			}
			IJ.log( "loop " + ( k + 1 ) + ": " + timer.stop() );
		}

		final ColorProcessor cpa = new ColorProcessor( screenImage.image() );
		imp.setProcessor( cpa );
		imp.updateAndDraw();
	}
 
开发者ID:imglib,项目名称:imglib2-tests,代码行数:81,代码来源:LanczosExample.java

示例15: registerEdgelsOrient

import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public void registerEdgelsOrient( Edgel e, Edgel f, int i )
	{
		ImagePlusImgFactory<T> ipfactory = new ImagePlusImgFactory<T>(); 
		Img<T> ePatch = ipfactory.create(patchSize, img.firstElement());
		Img<T> fPatch = ipfactory.create(patchSize, img.firstElement());
		
		computeCrackDepthNormalMask( e );	
		sampleImgByDepth( e, ePatch );
		
		computeCrackDepthNormalMask( f );	
		sampleImgByDepth( f, fPatch );
		
		ImgOps.writeFloat( ePatch, 
				String.format("%s/patchDepthSamp_test.tif", debugOutDir));
		ImgOps.writeFloat( fPatch, 
				String.format("%s/patchDepthSamp_test_match.tif", debugOutDir));
		
		Img<T> ePatch2 = ImgOps.collapseSum(ePatch);
		Img<T> fPatch2 = ImgOps.collapseSum(fPatch);
		
		int[] midPt = PatchTools.patchSizeToMidpt(patchSize);
		int[] midPtPatch = ArrayUtil.subArray(
				PatchTools.patchSizeToMidpt(patchSize),
				0, ePatch2.numDimensions());
		
		logger.debug(" end: " + (ePatch2.numDimensions() - 1));
		logger.debug(" midPt: " + ArrayUtil.printArray(midPtPatch));		
		int zdim = midPtPatch.length - 1; 
//		
//		IntervalView<T> ePatch2 = Views.hyperSlice( ePatch, zdim, midPt[zdim] );
//		IntervalView<T> fPatch2 = Views.hyperSlice( fPatch, zdim, midPt[zdim] );
		
		/** DEBUG WRITE TO FILE **/
		long[] min = new long[ePatch2.numDimensions()];
		ePatch2.min(min);
		long[] max = new long[ePatch2.numDimensions()];
		ePatch2.max(max);
		IntervalIterator itvl = new IntervalIterator( min, max );
//		
//		logger.debug(" patchout min: " + ArrayUtil.printArray(min));
//		logger.debug(" patchout max: " + ArrayUtil.printArray(max));
//		
		ImagePlusImg<T, ?> ePatch2out = ipfactory.create(itvl, img.firstElement());
		ImgOps.copyInto(ePatch2, ePatch2out);
		ImgOps.writeFloat( ePatch2out, 
				String.format("%s/patchDepthSamp_test_col.tif", debugOutDir));

		ImagePlusImg<T, ?> fPatch2out = ipfactory.create(itvl, img.firstElement());
		ImgOps.copyInto(fPatch2, fPatch2out);
		ImgOps.writeFloat( fPatch2out, 
				String.format("%s/patchDepthSamp_test_col_match.tif", debugOutDir));
		/** DEBUG WRITE TO FILE **/
		
		
		// register
		
		AffineTransform xfm = TransformTools.rotationPca(ePatch2, fPatch2, ArrayUtil.toDouble(midPtPatch));
		logger.debug("xfm : \n" + TransformTools.printAffineTransform(xfm));
		
		AffineTransform3D xfmPre = EdgelTools.edgelToXfm(f, midPt);
		xfmPre.preConcatenate(xfm);
		
		RealTransformRandomAccessible<T, InverseRealTransform> fPatch2Xfm = RealViews.transform( 
				Views.interpolate(img, new NLinearInterpolatorFactory<T>()), 
				xfmPre.inverse());
		
		ImagePlusImg<T, ?> fPatch2Xfmout = ipfactory.create(itvl, img.firstElement());
		ImgOps.copyInto(fPatch2Xfm, fPatch2Xfmout);
		ImgOps.writeFloat( fPatch2Xfmout, 
				String.format("%s/patchDepthSamp_test_col_match_Xfm.tif", debugOutDir));
	}
 
开发者ID:bogovicj,项目名称:hhmi-exp,代码行数:72,代码来源:CrackCorrection.java


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