本文整理汇总了Java中net.imglib2.realtransform.AffineTransform3D.copy方法的典型用法代码示例。如果您正苦于以下问题:Java AffineTransform3D.copy方法的具体用法?Java AffineTransform3D.copy怎么用?Java AffineTransform3D.copy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.realtransform.AffineTransform3D
的用法示例。
在下文中一共展示了AffineTransform3D.copy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInitialTransforms
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
*
* @param vr the ViewRegistration to decompose
* @param is2d true or false
* @param dsCorrectionT downsampling correction
* @return (1) the ViewRegistration without Translation part and the translation, with the inverse of (1) and dsCorrection applied
*/
public static Pair<AffineGet, TranslationGet> getInitialTransforms( final ViewRegistration vr, final boolean is2d, final AffineTransform3D dsCorrectionT )
{
AffineTransform3D model = vr.getModel().copy();
// get model without translation (last column set to 0)
AffineTransform3D modelWithoutTranslation = model.copy();
modelWithoutTranslation.set( 0, 0, 3 );
modelWithoutTranslation.set( 0, 1, 3 );
modelWithoutTranslation.set( 0, 2, 3 );
// the translation with inverse of other part of model applied
final double[] target = model.getTranslation();
modelWithoutTranslation.applyInverse( target, target );
// we go from big to downsampled, thats why the inverse
dsCorrectionT.applyInverse( target, target );
if ( is2d )
return new ValuePair<>(modelWithoutTranslation, new Translation2D( target[ 0 ], target[ 1 ] ));
else
return new ValuePair<>(modelWithoutTranslation, new Translation3D( target[ 0 ], target[ 1 ], target[ 2 ] ));
}
示例2: setMask
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
* Samples a patch of size N^d where d is the dimensionality of the
* source image src. The input transformation maps the x- and y-axes
* to the axes of the sampling plane and is typically determined by
* the {@link pickTransformation} method.
*
*
* @param basepos point
* @param N size of a dimension of the output patch
* @param xfm transformation
* @param src source image
* @return
*/
public static <L extends NumericType<L>> void setMask(float[] basepos, int[] patchSize,
AffineTransform3D xfmIn, RandomAccessible<L> src, L val ){
AffineTransform3D xfm = xfmIn.copy();
// AffineTransform3D xfm = xfmIn.inverse();
logger.debug("set edgel mask ");
logger.debug("xfm : " + xfm);
RandomAccess<L> ra = src.randomAccess();
// ra.setPosition(position);
int ndims_in = src.numDimensions();
logger.debug(" basepos :" + ArrayUtil.printArray( basepos ) );
logger.debug(" out size :" + ArrayUtil.printArray( patchSize ) );
double[] pos = new double[ndims_in];
double[] dpos = new double[ndims_in];
IntervalIterator iter = new IntervalIterator(patchSize);
while(iter.hasNext()){
iter.fwd();
iter.localize(pos);
xfm.apply( pos, dpos);
int[] pt = ArrayUtil.toIntRound(dpos);
logger.trace(" pt :" + ArrayUtil.printArray( pt ) );
ra.setPosition(pt);
ra.get().set(val);
}
}
示例3: main
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static void main(String[] args)
{
AffineTransform3D scale = new AffineTransform3D();
scale.scale( 2.0 );
//scale.rotate( 0, 45 );
AffineTransform3D translate = new AffineTransform3D();
translate.translate( new double[] {100.0, 100.0, 100.0} );
AffineTransform3D translate2 = new AffineTransform3D();
translate2.translate( new double[] {200.0, 200.0, 200.0} );
AffineTransform3D conc = scale.copy().preConcatenate( translate );
scale.scale( 3.0 );
AffineTransform3D conc2 = scale.copy().preConcatenate( translate2 );
//System.out.println( scale );
//System.out.println( translate );
System.out.println( conc );
System.out.println( conc2 );
RealPoint p1 = new RealPoint( 3 );
conc.apply( p1, p1 );
RealPoint p2 = new RealPoint( 3 );
conc2.apply( p2, p2 );
System.out.println( p1 );
System.out.println( p2 );
AffineTransform3D everythingbuttraslation = conc.copy();
everythingbuttraslation.set( 0, 0, 3 );
everythingbuttraslation.set( 0, 1, 3 );
everythingbuttraslation.set( 0, 2, 3 );
AffineTransform3D everythingbuttraslation2 = conc2.copy();
everythingbuttraslation2.set( 0, 0, 3 );
everythingbuttraslation2.set( 0, 1, 3 );
everythingbuttraslation2.set( 0, 2, 3 );
double[] trans1 = conc.getTranslation();
double[] trans2 = conc2.getTranslation();
everythingbuttraslation.inverse().apply( trans1, trans1 );
everythingbuttraslation2.inverse().apply( trans2, trans2 );
System.out.println( new RealPoint( trans1 ) );
System.out.println( new RealPoint( trans2 ) );
System.out.println( mapBackTransform( everythingbuttraslation, everythingbuttraslation2 ) );
}
示例4: 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 );
}
示例5: 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);
}
示例6: 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();
}
}
示例7: openVirtuallyFused
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public static <S extends AbstractSequenceDescription< ?,? extends BasicViewDescription<? extends BasicViewSetup>, ? >>
List<RandomAccessibleInterval< FloatType >> openVirtuallyFused(
S sd,
ViewRegistrations vrs,
Collection<? extends Collection<ViewId>> views,
Interval boundingBox,
double[] downsamplingFactors)
{
final BasicImgLoader imgLoader = sd.getImgLoader();
final List<RandomAccessibleInterval< FloatType >> openImgs = new ArrayList<>();
final Interval bbSc = TransformVirtual.scaleBoundingBox( new FinalInterval( boundingBox ), inverse( downsamplingFactors ));
final long[] dim = new long[ bbSc.numDimensions() ];
bbSc.dimensions( dim );
for (Collection<ViewId> viewGroup : views)
{
final ArrayList< RandomAccessibleInterval< FloatType > > images = new ArrayList<>();
final ArrayList< RandomAccessibleInterval< FloatType > > weights = new ArrayList<>();
for ( final ViewId viewId : viewGroup )
{
final ViewRegistration vr = vrs.getViewRegistration( viewId );
vr.updateModel();
AffineTransform3D model = vr.getModel();
final float[] blending = Util.getArrayFromValue( FusionTools.defaultBlendingRange, 3 );
final float[] border = Util.getArrayFromValue( FusionTools.defaultBlendingBorder, 3 );
model = model.copy();
TransformVirtual.scaleTransform( model, inverse(downsamplingFactors) );
final RandomAccessibleInterval inputImg = DownsampleTools.openDownsampled( imgLoader, viewId, model );
System.out.println( model.inverse() );
FusionTools.adjustBlending( sd.getViewDescriptions().get( viewId ), blending, border, model );
images.add( TransformView.transformView( inputImg, model, bbSc, 0, 1 ) );
weights.add( TransformWeight.transformBlending( inputImg, border, blending, model, bbSc ) );
}
openImgs.add( new FusedRandomAccessibleInterval( new FinalInterval( dim ), images, weights ) );
}
return openImgs;
}
示例8: warpToLandmark
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
public void warpToLandmark( int row, BigWarpViewerPanel viewer )
{
int offset = 0;
int ndims = landmarkModel.getNumdims();
double[] pt = null;
if( viewer.getIsMoving() && viewer.getOverlay().getIsTransformed() )
{
if ( BigWarp.this.landmarkModel.isWarped( row ) )
{
pt = LandmarkTableModel.toPrimitive( BigWarp.this.landmarkModel.getWarpedPoints().get( row ) );
}
else
{
offset = ndims;
}
}else if( !viewer.getIsMoving() )
{
offset = ndims;
}
if ( pt == null )
{
if ( ndims == 3 )
pt = new double[] {
(Double) landmarkModel.getValueAt( row, offset + 2 ),
(Double) landmarkModel.getValueAt( row, offset + 3 ),
(Double) landmarkModel.getValueAt( row, offset + 4 ) };
else
pt = new double[] {
(Double) landmarkModel.getValueAt( row, offset + 2 ),
(Double) landmarkModel.getValueAt( row, offset + 3 ), 0.0 };
}
// we have an unmatched point
if ( Double.isInfinite( pt[ 0 ] ) )
return;
final AffineTransform3D transform = viewer.getDisplay().getTransformEventHandler().getTransform();
final AffineTransform3D xfmCopy = transform.copy();
xfmCopy.set( 0.0, 0, 3 );
xfmCopy.set( 0.0, 1, 3 );
xfmCopy.set( 0.0, 2, 3 );
final double[] center = new double[] { viewer.getWidth() / 2, viewer.getHeight() / 2, 0 };
final double[] ptxfm = new double[ 3 ];
xfmCopy.apply( pt, ptxfm );
// select appropriate row in the table
landmarkTable.setRowSelectionInterval( row, row );
// this should work fine in the 2d case
final TranslationAnimator animator = new TranslationAnimator( transform, new double[] { center[ 0 ] - ptxfm[ 0 ], center[ 1 ] - ptxfm[ 1 ], -ptxfm[ 2 ] }, 300 );
viewer.setTransformAnimator( animator );
viewer.transformChanged( transform );
}
示例9: setMaskXfm
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
* Samples a patch of size N^d where d is the dimensionality of the
* source image src. The input transformation maps the x- and y-axes
* to the axes of the sampling plane and is typically determined by
* the {@link pickTransformation} method.
*
*
* @param basepos point
* @param N size of a dimension of the output patch
* @param xfm transformation
* @param src source image
* @return
*/
public static <L extends NumericType<L>> void setMaskXfm(double[] basepos, int[] patchSize,
AffineTransform3D xfmIn, RandomAccessible<L> src, L val ){
AffineTransform3D xfm = xfmIn.copy();
RandomAccess<L> ra = src.randomAccess();
// ra.setPosition(position);
int ndims_in = src.numDimensions();
logger.debug(" basepos :" + ArrayUtil.printArray( basepos ) );
logger.debug(" out size :" + ArrayUtil.printArray( patchSize ) );
double[] pos = new double[ndims_in];
double[] dpos = new double[ndims_in];
// determine translation
double[] midPt = ArrayUtil.toDouble(patchSize);
ArrayUtil.addInPlace(midPt, -1);
ArrayUtil.divide(midPt, 2);
logger.debug(" midPt :" + ArrayUtil.printArray( midPt ) );
double[] target = new double[ndims_in];
xfm.apply(midPt, target);
double[] diff = ArrayUtil.subtract( basepos, target );
logger.debug(" diff :" + ArrayUtil.printArray( diff ) );
for( int i=0; i<ndims_in; i++ ){
xfm.set( diff[i], i, ndims_in);
}
IntervalIterator iter = new IntervalIterator(patchSize);
while(iter.hasNext()){
iter.fwd();
iter.localize(pos);
xfm.apply( pos, dpos);
int[] pt = ArrayUtil.toIntRound(dpos);
logger.trace(" pt :" + ArrayUtil.printArray( pt ) );
ra.setPosition(pt);
ra.get().set(val);
}
}
示例10: ViewRegistration
import net.imglib2.realtransform.AffineTransform3D; //导入方法依赖的package包/类
/**
* Creates a new {@link ViewRegistration} object using one
* {@link AffineTransform3D} transform. The <code>transform</code> specifies
* a general affine transformation from view-local coordinates (pixels) to
* global coordinates.
*
* @param timepointId
* @param setupId
* @param transform
*/
public ViewRegistration( final int timepointId, final int setupId, final AffineTransform3D transform )
{
super( timepointId, setupId );
model = transform.copy();
transformList = new ArrayList< ViewTransform >();
transformList.add( new ViewTransformAffine( null, transform ) );
}