@Override public synchronized void getSourceTransform( final int t, final int level, final AffineTransform3D transform ) { source.getSourceTransform( t, level, transform ); transform.preConcatenate( sourceTransform ); }
transform.preConcatenate( tpTransforms.get( tp ) ); transform.preConcatenate( angleTransforms.get( angle ) ); transform.preConcatenate( channelTransforms.get( channel ) ); transform.preConcatenate( illumTransforms.get( illumination ) ); transform.preConcatenate( tileTransforms.get( tile ) );
/** * Scale the affine transform (use with scaleBoundingBox so it is the right image, but just smaller) * * @param t transform * @param factor scaling factor */ public static void scaleTransform( final AffineTransform3D t, final double factor ) { final AffineTransform3D at = new AffineTransform3D(); at.scale( factor ); t.preConcatenate( at ); }
public RandomAccessibleIntervalMipmapSource( final RandomAccessibleInterval< T >[] imgs, final T type, final double[][] mipmapScales, final VoxelDimensions voxelDimensions, final AffineTransform3D sourceTransform, final String name ) { super( type, name ); assert imgs.length == mipmapScales.length : "Number of mipmaps and scale factors do not match."; this.mipmapSources = imgs; this.mipmapTransforms = new AffineTransform3D[ mipmapScales.length ]; for ( int s = 0; s < mipmapScales.length; ++s ) { final AffineTransform3D mipmapTransform = new AffineTransform3D(); mipmapTransform.set( mipmapScales[ s ][ 0 ], 0, 0, 0.5 * ( mipmapScales[ s ][ 0 ] - 1 ), 0, mipmapScales[ s ][ 1 ], 0, 0.5 * ( mipmapScales[ s ][ 1 ] - 1 ), 0, 0, mipmapScales[ s ][ 2 ], 0.5 * ( mipmapScales[ s ][ 2 ] - 1 ) ); mipmapTransform.preConcatenate(sourceTransform); mipmapTransforms[ s ] = mipmapTransform; } this.voxelDimensions = voxelDimensions; }
/** * Get the mipmap level that best matches the given screen scale for the given source. * * @param screenScaleTransform * screen scale, transforms screen coordinates to viewer coordinates. * @return mipmap level */ public synchronized int getBestMipMapLevel( final AffineTransform3D screenScaleTransform, final int sourceIndex ) { final AffineTransform3D screenTransform = new AffineTransform3D(); getViewerTransform( screenTransform ); screenTransform.preConcatenate( screenScaleTransform ); final Source< ? > source = sources.get( sourceIndex ).getSpimSource(); return MipmapTransforms.getBestMipMapLevel( screenTransform, source, currentTimepoint ); }
@Override public void drawOverlays( final Graphics g ) { final Graphics2D graphics = ( Graphics2D ) g; final GeneralPath front = new GeneralPath(); final GeneralPath back = new GeneralPath(); final Interval interval = bbSource.getInterval(); final double perspective = 3; final double sourceSize = Math.max( Math.max( interval.dimension( 0 ), interval.dimension( 1 ) ), interval.dimension( 2 ) ); final double ox = canvasWidth / 2; final double oy = canvasHeight / 2; bbSource.getIntervalTransform( transform ); transform.preConcatenate( viewerTransform ); renderBoxHelper.setDepth( perspective * sourceSize ); renderBoxHelper.setOrigin( ox, oy ); renderBoxHelper.setScale( 1 ); renderBoxHelper.renderBox( interval, transform, front, back ); final AffineTransform t = graphics.getTransform(); final AffineTransform translate = new AffineTransform( 1, 0, 0, 1, ox, oy ); translate.preConcatenate( t ); graphics.setTransform( translate ); graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON ); graphics.setPaint( backColor ); graphics.draw( back ); graphics.setPaint( frontColor ); graphics.draw( front ); graphics.setTransform( t ); }
public static void scaleTransform( final AffineTransform3D t, final double[] factors ) { final AffineTransform at = new AffineTransform(t.numDimensions()); for (int d = 0; d < at.numDimensions(); d++) at.set( factors[d], d, d ); t.preConcatenate( at ); }
@Override public void transformChanged( final AffineTransform3D transform ) { if ( !active ) { return; } liveTransform.set( transform ); liveTransform.preConcatenate( frozenTransform.inverse() ); for ( final TransformedSource< ? > source : sourcesToFix ) source.setIncrementalTransform( liveTransform.inverse() ); }
@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 ) { final HashMap< ? extends ViewId, ? extends Collection< ? extends RealLocalizable > > coordinates = pointSource.getLocalCoordinates( t ); for ( final ViewId viewId : coordinates.keySet() ) { pointSource.getLocalToGlobalTransform( viewId, t, transform ); transform.preConcatenate( viewerTransform ); for ( final RealLocalizable p : coordinates.get( viewId ) ) { 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 ); } } } }
public static Pair< double[], AffineTransform3D > scaling( final Dimensions dim, final AffineTransform3D transformationModel ) { final AffineTransform3D transform = transformationModel.copy(); final AffineTransform3D mapBack = TransformationTools.computeMapBackModel( dim, new AffineTransform3D(), // identity TransformationTools.getModel( transform ), // current model new RigidModel3D() ); // what to use // reset translation mapBack.set( 0.0, 0, 3 ); mapBack.set( 0.0, 1, 3 ); mapBack.set( 0.0, 2, 3 ); //System.out.println( "MapBack: " + TransformationTools.printAffine3D( mapBack ) ); final AffineTransform3D atOrigin = transform.preConcatenate( mapBack ); //System.out.println( "At origin: " + TransformationTools.printAffine3D( atOrigin ) ); // there seems to be a bug in Transform3D, it does mix up the y/z dimensions sometimes // TransformationTools.getScaling( atOrigin, scale ); // the scale is approximately now the diagonal entries in the matrix // and we are only interested in the absolute value since it could be mirrored, in which case the scaling is negative return new ValuePair<>( new double[]{ Math.abs( atOrigin.get( 0, 0 ) ), Math.abs( atOrigin.get( 1, 1 ) ), Math.abs( atOrigin.get( 2, 2 ) ) }, mapBack ); }
res.preConcatenate( translateToCenter.inverse() ); res.preConcatenate( rot ); res.preConcatenate( translateToCenter );
public static <V> void storeTransformation( final ViewRegistration vr, final V viewId, final Tile< ? > tile, final AffineGet mapBackModel, final String modelDescription ) { final AffineTransform3D t; if ( tile != null ) { // TODO: we assume that M is an Affine3D, which is not necessarily true t = getAffineTransform( (Affine3D< ? >)tile.getModel() ); } else { // it might have been removed prior to global optimization because it has no links t = new AffineTransform3D(); } if ( mapBackModel != null ) t.preConcatenate( mapBackModel ); final ViewTransform vt = new ViewTransformAffine( modelDescription, t ); vr.preconcatenateTransform( vt ); vr.updateModel(); }
screenTransform.preConcatenate( screenScaleTransform ); final MipmapHints hints = ordering.getMipmapHints( screenTransform, t, previousTimepoint ); final List< Level > levels = hints.getLevels();
source.setIncrementalTransform( tmp ); source.getFixedTransform( tmp ); tmp.preConcatenate( liveTransform ); source.setFixedTransform( tmp );
private static < T > RandomAccessible< T > getTransformedSource( final ViewerState viewerState, final Source< T > source, final AffineTransform3D screenScaleTransform, final int mipmapIndex, final CacheHints cacheHints ) { final int timepoint = viewerState.getCurrentTimepoint(); final RandomAccessibleInterval< T > img = source.getSource( timepoint, mipmapIndex ); if ( VolatileCachedCellImg.class.isInstance( img ) ) ( ( VolatileCachedCellImg< ?, ? > ) img ).setCacheHints( cacheHints ); final Interpolation interpolation = viewerState.getInterpolation(); final RealRandomAccessible< T > ipimg = source.getInterpolatedSource( timepoint, mipmapIndex, interpolation ); final AffineTransform3D sourceToScreen = new AffineTransform3D(); viewerState.getViewerTransform( sourceToScreen ); final AffineTransform3D sourceTransform = new AffineTransform3D(); source.getSourceTransform( timepoint, mipmapIndex, sourceTransform ); sourceToScreen.concatenate( sourceTransform ); sourceToScreen.preConcatenate( screenScaleTransform ); return RealViews.affine( ipimg, sourceToScreen ); }
0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0/quality.getAnisotropyFactor(), 0.0 ); transform.preConcatenate( aniso );
source.getSourceTransform( timepoint, mipmapIndex, sourceTransform ); sourceToScreen.concatenate( sourceTransform ); sourceToScreen.preConcatenate( screenScaleTransform );
@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 double[] qAddCurrent = new double[4]; final AffineTransform3D tAddCurrent = new AffineTransform3D(); LinAlgHelpers.quaternionPower( qAddEnd, t, qAddCurrent ); final double[][] m = new double[3][4]; LinAlgHelpers.quaternionToR( qAddCurrent, m ); tAddCurrent.set( m ); 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; } }
0, 1, 0, sourceInterval.min( 1 ), 0, 0, 1, sourceInterval.min( 2 ) ); croppedSourceTransform.preConcatenate( sourceToGlobal );
currentViewerTransform.set( 0, 2, 3 ); currentViewerTransform.preConcatenate( scale );