本文整理汇总了Java中bdv.viewer.Source.getSource方法的典型用法代码示例。如果您正苦于以下问题:Java Source.getSource方法的具体用法?Java Source.getSource怎么用?Java Source.getSource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bdv.viewer.Source
的用法示例。
在下文中一共展示了Source.getSource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: create
import bdv.viewer.Source; //导入方法依赖的package包/类
@Override
public TrackMateModelView create( final Model model, final Settings settings, final SelectionModel selectionModel )
{
final SourceSettings ss = ( SourceSettings ) settings;
final List< SourceAndConverter< ? >> sources = ss.getSources();
final int numTimePoints = ss.nframes;
final CacheControl cache = ss.getCacheControl();
final Bookmarks bookmarks = new Bookmarks();
// Test if we have 2D images.
boolean is2D = true;
for ( final SourceAndConverter< ? > sac : sources )
{
final Source< ? > source = sac.getSpimSource();
for ( int t = 0; t < numTimePoints; t++ )
{
if ( source.isPresent( t ) )
{
final RandomAccessibleInterval< ? > level = source.getSource( t, 0 );
if ( level.dimension( 2 ) > 1 )
is2D = false;
break;
}
}
}
final ViewerOptions options = ViewerOptions.options();
if ( is2D )
options.transformEventHandlerFactory( BehaviourTransformEventHandlerPlanar.factory() );
return new MamutViewer( DEFAULT_WIDTH, DEFAULT_HEIGHT,
sources, numTimePoints, cache,
model, selectionModel,
options,
bookmarks );
}
示例2: getImgPatch
import bdv.viewer.Source; //导入方法依赖的package包/类
@SuppressWarnings( { "rawtypes", "unchecked" } )
public static final Img< ? > getImgPatch( final long[] pos, final int frame, final int width, final int height, final int depth, final Source source )
{
/*
* Here be generics massacre...
*/
final Type type = ( Type ) source.getType();
final RealType rtype = ( RealType ) type.createVariable();
rtype.setZero();
final NativeType ntype = ( NativeType ) rtype;
final long[] size = new long[] { width, height, depth };
final RandomAccessibleInterval img = source.getSource( frame, 0 );
// Get coords
final long x = pos[ 0 ];
final long y = pos[ 1 ];
final long z = pos[ 2 ];
final int xp = width / 2;
final int xm = width - xp;
final int yp = height / 2;
final int ym = height - yp;
final int zp = depth / 2;
final int zm = depth - zp;
// Crop
final Interval cropInterval = Intervals.createMinMax( x - xm, y - ym, z - zm, x + xp, y + yp, z + zp );
if ( isEmpty( cropInterval ) )
{
final Img ret = new ArrayImgFactory().create( size, ntype );
return ret;
}
else
{
final ExtendedRandomAccessibleInterval extendZero = Views.extendZero( img );
final IntervalView crop = Views.zeroMin( Views.interval( extendZero, cropInterval ) );
final Img target = Util.getArrayOrCellImgFactory( crop, ntype ).create( size, ntype );
final RandomAccess randomAccess = crop.randomAccess();
final Cursor cursor = target.localizingCursor();
while ( cursor.hasNext() )
{
cursor.fwd();
randomAccess.setPosition( cursor );
( ( Type ) cursor.get() ).set( ( Type ) randomAccess.get() );
}
return target;
}
}