本文整理汇总了Java中net.imglib2.view.Views.extendValue方法的典型用法代码示例。如果您正苦于以下问题:Java Views.extendValue方法的具体用法?Java Views.extendValue怎么用?Java Views.extendValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.view.Views
的用法示例。
在下文中一共展示了Views.extendValue方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLeadingZeros
import net.imglib2.view.Views; //导入方法依赖的package包/类
/**
* Add 0s before axis minimum.
*
* @param input Input RAI
* @return An extended and cropped version of input
*/
private <T extends RealType<T>> RandomAccessibleInterval<T> addLeadingZeros(
RandomAccessibleInterval<T> input)
{
final long[] min = Intervals.minAsLongArray(input);
final long[] max = Intervals.maxAsLongArray(input);
for (int i = 0; i < max.length; i++) {
min[i]--;
}
final T realZero = Util.getTypeFromInterval(input).copy();
realZero.setZero();
final ExtendedRandomAccessibleInterval<T, RandomAccessibleInterval<T>> extendedImg = Views.extendValue(input,
realZero);
final IntervalView<T> offsetInterval = Views.interval(extendedImg,
min, max);
return Views.zeroMin(offsetInterval);
}
示例2: NeuronIdsToFileController
import net.imglib2.view.Views; //导入方法依赖的package包/类
public NeuronIdsToFileController(
final ViewerPanel viewer,
final RandomAccessibleInterval< LongType > labels,
final AffineTransform3D labelTransform,
final FragmentSegmentAssignment assignment,
final SelectionController selectionController,
final int[] labelsH5CellDimensions,
final InputTriggerConfig config,
final int brushNormalAxis )
{
this.viewer = viewer;
this.labels = labels;
extendedLabels = Views.extendValue( this.labels, new LongType( Label.TRANSPARENT ) );
this.labelTransform = labelTransform;
this.assignment = assignment;
this.selectionController = selectionController;
this.labelsH5CellDimensions = labelsH5CellDimensions;
this.brushNormalAxis = brushNormalAxis;
brushOverlay = new BrushOverlay( viewer );
inputAdder = config.inputTriggerAdder( inputTriggerMap, "brush" );
labelLocation = new RealPoint( 3 );
new StoreId("store ids", "Q button1").register();;
// new Paint( "paint", "SPACE button1" ).register();
// new Erase( "erase", "SPACE button2", "SPACE button3" ).register();
// new ChangeBrushRadius( "change brush radius", "SPACE scroll" ).register();
// new MoveBrush( "move brush", "SPACE" ).register();
}
示例3: fillMask
import net.imglib2.view.Views; //导入方法依赖的package包/类
private < T extends BooleanType< T > > GrowingStoreRandomAccessibleSingletonAccess< T > fillMask( final AffineTransform3D tf, final long[] initialMin, final long[] initialMax, final Point p, final GrowingStoreRandomAccessibleSingletonAccess.Factory< T > factory, final T notVisited, final T fillLabel )
{
final GrowingStoreRandomAccessibleSingletonAccess< T > tmpFill = new GrowingStoreRandomAccessibleSingletonAccess<>( initialMin, initialMax, factory, notVisited.createVariable() );
final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels = new AccessBoxRandomAccessible<>(
Views.extendValue(
paintedLabels,
new LongType( Label.TRANSPARENT ) ) );
final AffineRandomAccessible< LongType, AffineGet > transformedPaintedLabels =
RealViews.affine(
Views.interpolate(
accessTrackingExtendedPaintedLabels,
new NearestNeighborInterpolatorFactory<>() ),
tf );
final MixedTransformView< LongType > hyperSlice = Views.hyperSlice( Views.raster( transformedPaintedLabels ), 2, 0 );
final AffineRandomAccessible< LabelMultisetType, AffineGet > transformedLabels = RealViews.affine( Views.interpolate( Views.extendValue( labels, new LabelMultisetType() ), new NearestNeighborInterpolatorFactory<>() ), tf );
final MixedTransformView< LabelMultisetType > hyperSliceLabels = Views.hyperSlice( Views.raster( transformedLabels ), 2, 0 );
final RandomAccessiblePair< LabelMultisetType, LongType > labelsPaintedLabelsPair = new RandomAccessiblePair<>( hyperSliceLabels, hyperSlice );
final RandomAccessiblePair< LabelMultisetType, LongType >.RandomAccess pairAccess = labelsPaintedLabelsPair.randomAccess();
pairAccess.setPosition( p );
final long seedPaint = pairAccess.get().getB().getIntegerLong();
final long seedFragmentLabel = getBiggestLabel( pairAccess.getA() );
FloodFill.fill( labelsPaintedLabelsPair, tmpFill, p, new ValuePair< LabelMultisetType, LongType >( new LabelMultisetType(), new LongType( selectionController.getActiveFragmentId() ) ), fillLabel, new DiamondShape( 1 ), new SegmentAndPaintFilter2D< T >( seedPaint, seedFragmentLabel, assignment ), new TypeWriter<>() );
dirtyLabelsInterval.touch( accessTrackingExtendedPaintedLabels.createAccessInterval() );
return tmpFill;
}
示例4: writeMask
import net.imglib2.view.Views; //导入方法依赖的package包/类
private void writeMask( final GrowingStoreRandomAccessibleSingletonAccess< BitType > tmpFill, final AffineTransform3D tf, final long label )
{
final IntervalView< BitType > tmpFillInterval = Views.interval( tmpFill, tmpFill.getIntervalOfSizeOfStore() );
final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels = new AccessBoxRandomAccessible<>(
Views.extendValue(
paintedLabels,
new LongType( Label.TRANSPARENT ) ) );
final AffineRandomAccessible< LongType, AffineGet > transformedPaintedLabels =
RealViews.affine(
Views.interpolate(
accessTrackingExtendedPaintedLabels,
new NearestNeighborInterpolatorFactory<>() ),
tf );
final MixedTransformView< LongType > hyperSlice = Views.hyperSlice( Views.raster( transformedPaintedLabels ), 2, 0 );
final net.imglib2.Cursor< BitType > s = tmpFillInterval.cursor();
final net.imglib2.Cursor< LongType > t = Views.interval( hyperSlice, tmpFillInterval ).cursor();
while ( s.hasNext() )
{
t.fwd();
if ( s.next().get() )
t.get().set( label );
}
dirtyLabelsInterval.touch( accessTrackingExtendedPaintedLabels.createAccessInterval() );
}
示例5: LabelBrushController
import net.imglib2.view.Views; //导入方法依赖的package包/类
public LabelBrushController(
final ViewerPanel viewer,
final RandomAccessibleInterval< LongType > labels,
final DirtyInterval dirtyLabelsInterval,
final AffineTransform3D labelTransform,
final FragmentSegmentAssignment assignment,
final SelectionController selectionController,
final int[] labelsH5CellDimensions,
final InputTriggerConfig config,
final int brushNormalAxis )
{
this.viewer = viewer;
this.labels = labels;
extendedLabels = Views.extendValue( this.labels, new LongType( Label.TRANSPARENT ) );
this.dirtyLabelsInterval = dirtyLabelsInterval;
this.labelTransform = labelTransform;
this.assignment = assignment;
this.selectionController = selectionController;
this.labelsH5CellDimensions = labelsH5CellDimensions;
this.brushNormalAxis = brushNormalAxis;
brushOverlay = new BrushOverlay( viewer );
inputAdder = config.inputTriggerAdder( inputTriggerMap, "brush" );
labelLocation = new RealPoint( 3 );
new Paint( "paint", "SPACE button1" ).register();
new Erase( "erase", "SPACE button2", "SPACE button3" ).register();
new ChangeBrushRadius( "change brush radius", "SPACE scroll" ).register();
new MoveBrush( "move brush", "SPACE" ).register();
}
示例6: getInterpolatedSource
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public RealRandomAccessible< VolatileARGBType > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
final ExtendedRandomAccessibleInterval< VolatileARGBType, RandomAccessibleInterval< VolatileARGBType > > extendedSource =
Views.extendValue( getSource( t, level ), new VolatileARGBType( 0 ) );
switch ( method )
{
case NLINEAR :
return Views.interpolate( extendedSource, interpolatorFactories[ 1 ] );
default :
return Views.interpolate( extendedSource, interpolatorFactories[ 0 ] );
}
}
示例7: stripToMatrix
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static < T extends Type< T > > RandomAccessibleInterval< T >
stripToMatrix( final RandomAccessibleInterval< T > strip, final T dummy )
{
final ExtendedRandomAccessibleInterval< T, RandomAccessibleInterval< T > > extended = Views.extendValue( strip, dummy );
final AbstractShearTransform tf = new ShearTransform( 2, 0, 1 ).inverse();
final long w = strip.dimension( 0 ) / 2;
final long h = strip.dimension( 1 );
final FinalInterval interval = new FinalInterval( new long[] { w, 0 }, new long[] { h + w - 1, h - 1 } );
final IntervalView< T > transformed = Views.offsetInterval( new TransformView<>( extended, tf ), interval );
return transformed;
}
示例8: matrixToStrip
import net.imglib2.view.Views; //导入方法依赖的package包/类
public static < T extends Type< T > > RandomAccessibleInterval< T >
matrixToStrip( final RandomAccessibleInterval< T > matrix, final int range, final T dummy )
{
final ExtendedRandomAccessibleInterval< T, RandomAccessibleInterval< T > > extended = Views.extendValue( matrix, dummy );
final AbstractShearTransform tf = new ShearTransform( 2, 0, 1 );
final long h = matrix.dimension( 1 );
final FinalInterval interval = new FinalInterval( new long[] { -range, 0 }, new long[] { range, h - 1 } );
final IntervalView< T > transformed = Views.offsetInterval( new TransformView<>( extended, tf ), interval );
return transformed;
}
示例9:
import net.imglib2.view.Views; //导入方法依赖的package包/类
private ExtendedRandomAccessibleInterval<B, RandomAccessibleInterval<B>>
extendInterval(RandomAccessibleInterval<B> interval)
{
final B type = Util.getTypeFromInterval(interval).createVariable();
type.set(in2());
return Views.extendValue(interval, type);
}
示例10: click
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public void click( final int x, final int y )
{
synchronized ( viewer )
{
if ( idPicker.getIdAtDisplayCoordinate( x, y ) == Label.OUTSIDE )
return;
viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
setCoordinates( x, y );
System.out.println( "Filling " + labelLocation + " with " + selectionController.getActiveFragmentId() );
final Point p = new Point( Math.round( labelLocation.getDoublePosition( 0 ) ), Math.round( labelLocation.getDoublePosition( 1 ) ), Math.round( labelLocation.getDoublePosition( 2 ) ) );
final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels =
new AccessBoxRandomAccessible<>(
Views.extendValue(
paintedLabels,
new LongType( Label.TRANSPARENT ) ) );
final RandomAccess< LongType > paintAccess = accessTrackingExtendedPaintedLabels.randomAccess();
paintAccess.setPosition( p );
final long seedPaint = paintAccess.get().getIntegerLong();
final long seedFragmentLabel = getBiggestLabel( labels, p );
final long t0 = System.currentTimeMillis();
FloodFill.fill(
Views.extendValue( labels, new LabelMultisetType() ),
accessTrackingExtendedPaintedLabels,
p,
new LabelMultisetType(),
new LongType( selectionController.getActiveFragmentId() ),
new DiamondShape( 1 ),
new SegmentAndPaintFilter1( seedPaint, seedFragmentLabel, assignment ) );
dirtyLabelsInterval.touch( accessTrackingExtendedPaintedLabels.createAccessInterval() );
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();
}
}
示例11: doOnUnToggle
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public void doOnUnToggle( final int x, final int y )
{
synchronized ( viewer )
{
viewer.setCursor( Cursor.getPredefinedCursor( Cursor.WAIT_CURSOR ) );
setCoordinates( x, y );
final Point p = new Point( Math.round( labelLocation.getDoublePosition( 0 ) ), Math.round( labelLocation.getDoublePosition( 1 ) ), Math.round( labelLocation.getDoublePosition( 2 ) ) );
final ArrayImg< ByteType, ByteArray > img = wrapBufferedImage( filledPixelsOverlay.img );
final ArrayRandomAccess< ByteType > imgAccess = img.randomAccess();
imgAccess.setPosition( new int[] { x, y } );
final byte overlayValueAtPoint = imgAccess.get().get();
final ExtendedRandomAccessibleInterval< ByteType, IntervalView< ByteType > > borderExtended = Views.extendBorder( Views.interval( Views.addDimension( img ), new FinalInterval( img.dimension( 0 ), img.dimension( 1 ), overlayValueAtPoint ) ) );
final RandomAccessibleOnRealRandomAccessible< ByteType > interpolatedAndTransformed =
Views.raster( RealViews.transform( Views.interpolate( borderExtended, new NearestNeighborInterpolatorFactory<>() ), labelTransform.inverse().copy().concatenate( viewerToGlobalCoordinatesTransform.inverse() )// toLabelSpace
) );
final long seedFragmentLabel = LabelFillController.getBiggestLabel( labels, p );
System.out.println( seedFragmentLabel + " " + overlayValueAtPoint + " " + getColor().getRGB() );
final RandomAccess< LongType > paintedLabelAccess = paintedLabels.randomAccess();
paintedLabelAccess.setPosition( p );
final long paintedLabel = paintedLabelAccess.get().get();
final long segmentLabel = assignment.getSegment( seedFragmentLabel );
final long comparison = paintedLabel == TRANSPARENT ? segmentLabel : paintedLabel;
final long[] fragmentsContainedInSegment = assignment.getFragments( segmentLabel );
final Filter< Pair< Pair< LabelMultisetType, ByteType >, LongType >, Pair< Pair< LabelMultisetType, ByteType >, LongType > > filter = ( p1, p2 ) -> {
final Pair< LabelMultisetType, ByteType > multiSetOverlayPairComp = p1.getA();
final long currentPaint = p1.getB().get();
if ( multiSetOverlayPairComp.getB().get() == overlayValueAtPoint && currentPaint != p2.getB().get() )
{
if ( currentPaint != TRANSPARENT )
return currentPaint == comparison;
else
{
final LabelMultisetType currentMultiSet = multiSetOverlayPairComp.getA();
for ( final long fragment : fragmentsContainedInSegment )
if ( currentMultiSet.contains( fragment ) )
return true;
return false;
}
}
return false;
};
final long t0 = System.currentTimeMillis();
final AccessBoxRandomAccessible< LongType > accessTrackingExtendedPaintedLabels =
new AccessBoxRandomAccessible<>(
Views.extendValue(
paintedLabels,
new LongType( Label.TRANSPARENT ) ) );
FloodFill.fill( new RandomAccessiblePair<>(
Views.extendValue( labels, new LabelMultisetType() ),
interpolatedAndTransformed ),
accessTrackingExtendedPaintedLabels,
p,
new ValuePair<>( new LabelMultisetType(), new ByteType( overlayValueAtPoint ) ),
new LongType( selectionController.getActiveFragmentId() ),
new DiamondShape( 1 ),
filter );
dirtyLabelsInterval.touch( accessTrackingExtendedPaintedLabels.createAccessInterval() );
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();
}
action.run();
}
示例12: main
import net.imglib2.view.Views; //导入方法依赖的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();
}
示例13: calculate
import net.imglib2.view.Views; //导入方法依赖的package包/类
@Override
public ExtendedRandomAccessibleInterval<T, F> calculate(F input) {
return Views.extendValue(input, value);
}