本文整理汇总了Java中net.imglib2.RealRandomAccessible类的典型用法代码示例。如果您正苦于以下问题:Java RealRandomAccessible类的具体用法?Java RealRandomAccessible怎么用?Java RealRandomAccessible使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RealRandomAccessible类属于net.imglib2包,在下文中一共展示了RealRandomAccessible类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInterpolatedSource
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
@Override
public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
if( isTransformed )
{
final AffineTransform3D transform = new AffineTransform3D();
source.getSourceTransform( t, level, transform );
final RealRandomAccessible< T > sourceRealAccessible = RealViews.affineReal( source.getInterpolatedSource( t, level, method ), transform );
if( xfm == null )
return sourceRealAccessible;
else
return new RealTransformRealRandomAccessible< T, InverseRealTransform >( sourceRealAccessible, xfm );
}
else
{
return source.getInterpolatedSource( t, level, method );
}
}
示例2: main
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
imp.show();
final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );
final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
for ( int i = 0; i < lut.length; ++i )
lut[ i ] = i + Math.pow( i, 1.5 );
final SingleDimensionLUTRealTransform transform = new SingleDimensionLUTRealTransform( lut, 2, 2, 1 );
final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );
// RealViews.transformReal(source, transform);
ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
}
示例3: render
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public static < T extends Type< T > > void render( final RealRandomAccessible< T > source, final RandomAccessibleInterval< T > target, final RealTransform transform, final double dx )
{
final RealRandomAccessible< T > interpolant = Views.interpolate( Views.extendBorder( target ), new NearestNeighborInterpolatorFactory< T >() );
final RealRandomAccess< T > a = source.realRandomAccess();
final RealRandomAccess< T > b = interpolant.realRandomAccess();
for ( double y = 0; y < target.dimension( 1 ); y += dx )
{
a.setPosition( y, 1 );
for ( double x = 0; x < target.dimension( 0 ); x += dx )
{
a.setPosition( x, 0 );
transform.apply( a, b );
b.get().set( a.get() );
}
}
}
示例4: getAccessor
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
/**
* Logic stolen from
* <a href='https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/org/janelia/intensity/LinearIntensityMap.java'>
* TrakEM2 LinearIntensityMap
* </a>.
*
* @return an accessor for deriving warped pixel intensities.
*/
public RealRandomAccess<RealComposite<DoubleType>> getAccessor() {
final ArrayImg<DoubleType, DoubleArray> warpField =
ArrayImgs.doubles(values, columnCount, rowCount, VALUES_PER_AFFINE);
final CompositeIntervalView<DoubleType, RealComposite<DoubleType>>
collapsedSource = Views.collapseReal(warpField);
final RandomAccessible<RealComposite<DoubleType>> extendedCollapsedSource = Views.extendBorder(collapsedSource);
final RealRandomAccessible<RealComposite<DoubleType>> coefficients =
Views.interpolate(extendedCollapsedSource, interpolatorFactory);
final double xScale = getXScale();
final double yScale = getYScale();
final double[] scale = { xScale, yScale };
final double[] shift = { 0.5 * xScale , 0.5 * yScale };
final ScaleAndTranslation scaleAndTranslation = new ScaleAndTranslation(scale, shift);
final RealRandomAccessible<RealComposite<DoubleType>> stretchedCoefficients =
RealViews.transform(coefficients, scaleAndTranslation);
return stretchedCoefficients.realRandomAccess();
}
示例5: defaultRasterTest
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
@Test
public void defaultRasterTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
RealRandomAccessible<DoubleType> realImg = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>());
RandomAccessibleOnRealRandomAccessible<DoubleType> il2 = Views.raster(realImg);
RandomAccessibleOnRealRandomAccessible<DoubleType> opr = ops.transform().rasterView(realImg);
Cursor<DoubleType> il2C = Views.interval(il2, img).localizingCursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, img).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
示例6: getInterpolatedSource
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
@Override
public RealRandomAccessible< T > getInterpolatedSource( final int t, final int level, final Interpolation method )
{
InterpolatorFactory< T, RandomAccessible< T >> factory;
switch ( method )
{
default:
case NEARESTNEIGHBOR:
factory = new NearestNeighborInterpolatorFactory< T >();
break;
case NLINEAR:
factory = new NLinearInterpolatorFactory< T >();
break;
}
final T zero = img.firstElement().createVariable();
zero.setZero();
return Views.interpolate( Views.extendValue( getSource( t, level ), zero ), factory );
}
示例7: updateRealRandomSource
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
/**
* Update the realRandomSource with new source.
* @param source
*/
public void updateRealRandomSource(final RealRandomAccessible source)
{
if(InteractiveRealViewer2D.class.isInstance(currentInteractiveViewer2D))
{
// User doesn't load any picture
((InteractiveRealViewer2D) currentInteractiveViewer2D).updateSource(source);
}
// else
// {
// // In case that user loaded InteractiveViewer2D already,
// // We're changing to InteractiveRealViewer2D for the updating source
// currentInteractiveViewer2D = interactiveRealViewer2D;
//
// editor.remove(view);
// InteractiveDrawingView newView = getCurrentInteractiveViewer2D().getJHotDrawDisplay();
// newView.copyFrom(view);
//
// editor.add(newView);
// view = newView;
//
// scrollPane.setViewportView(view);
//
// ((InteractiveRealViewer2D) currentInteractiveViewer2D).updateSource(source);
// }
}
示例8: LabelMultiSetIdPicker
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public LabelMultiSetIdPicker(
final ViewerPanel viewer,
final RealRandomAccessible< LabelMultisetType > labels )
{
this.viewer = viewer;
this.labels = labels;
labelAccess = labels.realRandomAccess();
}
示例9: PairLabelMultiSetLongIdPicker
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public PairLabelMultiSetLongIdPicker(
final ViewerPanel viewer,
final RealRandomAccessible< Pair< LabelMultisetType, LongType > > labels )
{
this.viewer = viewer;
this.labels = labels;
labelAccess = labels.realRandomAccess();
}
示例10: getInterpolatedSource
import net.imglib2.RealRandomAccessible; //导入依赖的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 ] );
}
}
示例11: copyToImageStack
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public static < T extends NumericType< T > & NativeType< T > > ImagePlus copyToImageStack( final RealRandomAccessible< T > rai, final Interval itvl )
{
final long[] dimensions = new long[ itvl.numDimensions() ];
itvl.dimensions( dimensions );
// create the image plus image
final T t = rai.realRandomAccess().get();
final ImagePlusImgFactory< T > factory = new ImagePlusImgFactory< T >();
final ImagePlusImg< T, ? > target = factory.create( itvl, t );
double k = 0;
final long N = dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ];
final net.imglib2.Cursor< T > c = target.cursor();
final RealRandomAccess< T > ra = rai.realRandomAccess();
while ( c.hasNext() )
{
c.fwd();
ra.setPosition( c );
c.get().set( ra.get() );
if ( k % 10000 == 0 )
{
IJ.showProgress( k / N );
}
k++;
}
IJ.showProgress( 1.1 );
try
{
return target.getImagePlus();
}
catch ( final ImgLibException e )
{
e.printStackTrace();
}
return null;
}
示例12: generateTransformed
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public static < T extends RealType< T > > RealRandomAccessible< T > generateTransformed(
final RandomAccessibleInterval< T > input,
final Transform permutation,
final InvertibleRealTransform lut,
final T dummy )
{
dummy.setReal( Double.NaN );
final IntervalView< T > permuted = Views.interval( new TransformView< T >( input, permutation ), input );
final RealRandomAccessible< T > interpolated = Views.interpolate( Views.extendValue( permuted, dummy ), new NLinearInterpolatorFactory< T >() );
return RealViews.transformReal( interpolated, lut );
}
示例13: generateStack
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
public static < T extends RealType< T > > ImageStack generateStack(
final RealRandomAccessible< T > input,
final int width,
final int height,
final int size,
final double zScale )
{
final Scale3D scaleTransform = new Scale3D( 1.0, 1.0, zScale );
final RealTransformRealRandomAccessible< T, InverseRealTransform > scaledInput = RealViews.transformReal( input, scaleTransform );
final int scaledSize = ( int ) ( size * zScale );
return generateStack( scaledInput, width, height, scaledSize );
}
示例14: main
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
final static public void main( final String[] args )
{
new ImageJ();
final ImagePlus imp = new ImagePlus( "http://media.npr.org/images/picture-show-flickr-promo.jpg" );
imp.show();
final float[] pixels = ( float[] ) imp.getProcessor().convertToFloat().getPixels();
final ArrayImg< FloatType, FloatArray > img = ArrayImgs.floats( pixels, imp.getWidth(), imp.getHeight() );
final double[] lut = new double[ Math.max( imp.getWidth(), imp.getHeight() ) ];
for ( int i = 0; i < lut.length; ++i )
lut[ i ] = i + Math.pow( i, 1.5 );
final LUTRealTransform transform = new LUTRealTransform( lut, 2, 2 );
final RealRandomAccessible< FloatType > source = Views.interpolate( Views.extendBorder( img ), new NLinearInterpolatorFactory< FloatType >() );
final RandomAccessible< FloatType > target = new RealTransformRandomAccessible< FloatType, RealTransform >( source, transform );
final RandomAccessible< FloatType > target2 = RealViews.transform( source, transform );
// RealViews.transformReal(source, transform);
final ArrayImg< FloatType, FloatArray > targetImg = ArrayImgs.floats( imp.getWidth(), imp.getHeight() );
render( source, targetImg, transform, 0.05 );
ImageJFunctions.show( Views.interval( target, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( Views.interval( target2, new FinalInterval( imp.getWidth(), imp.getHeight() ) ) );
ImageJFunctions.show( targetImg );
}
示例15: interpolateView
import net.imglib2.RealRandomAccessible; //导入依赖的package包/类
/**
* Returns a {@link RealRandomAccessible} using interpolation
*
* @param input the {@link EuclideanSpace} to be interpolated
* @param factory the {@link InterpolatorFactory} to provide interpolators for
* source
* @return
*/
@OpMethod(
op = net.imagej.ops.transform.interpolateView.DefaultInterpolateView.class)
public <T, I extends EuclideanSpace> RealRandomAccessible<T> interpolateView(
final I input, final InterpolatorFactory<T, I> factory)
{
return (RealRandomAccessible<T>) ops().run(
Ops.Transform.InterpolateView.class, input, factory);
}