本文整理汇总了Java中net.imglib2.RandomAccessible类的典型用法代码示例。如果您正苦于以下问题:Java RandomAccessible类的具体用法?Java RandomAccessible怎么用?Java RandomAccessible使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RandomAccessible类属于net.imglib2包,在下文中一共展示了RandomAccessible类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: gradient
import net.imglib2.RandomAccessible; //导入依赖的package包/类
/**
* Compute the partial derivative of source in a particular dimension.
*
* @param source
* source image, has to provide valid data in the interval of the
* gradient image plus a one pixel border in dimension.
* @param target
* output image, the partial derivative of source in the
* specified dimension.
* @param dimension
* along which dimension the partial derivatives are computed
* @param <T> pixel type source
* @param <S> pixel type target
*/
public static < T extends RealType< T >, S extends RealType< S > > void gradient(
final RandomAccessible< T > source,
final RandomAccessibleInterval< S > target,
final int dimension )
{
final Cursor< T > front = Views.flatIterable(
Views.interval( source,
Intervals.translate( target, 1, dimension ) ) ).cursor();
final Cursor< T > back = Views.flatIterable(
Views.interval( source,
Intervals.translate( target, -1, dimension ) ) ).cursor();
for( final S t : Views.flatIterable( target ) )
{
t.setReal( front.next().getRealDouble() - back.next().getRealDouble());
t.mul( 0.5 );
}
}
示例2: paint
import net.imglib2.RandomAccessible; //导入依赖的package包/类
protected void paint( final RealLocalizable coords)
{
final AccessBoxRandomAccessible< LongType > accessBoxExtendedLabels = new AccessBoxRandomAccessible<>( extendedLabels );
final RandomAccessible< LongType > labelSource = Views.hyperSlice( accessBoxExtendedLabels, brushNormalAxis, Math.round( coords.getDoublePosition( 2 ) ) );
final Neighborhood< LongType > sphere =
HyperSphereNeighborhood.< LongType >factory().create(
new long[]{
Math.round( coords.getDoublePosition( brushNormalAxis == 0 ? 1 : 0 ) ),
Math.round( coords.getDoublePosition( brushNormalAxis == 2 ? 1 : 2 ) ) },
Math.round( brushRadius / Affine3DHelpers.extractScale( labelTransform, brushNormalAxis == 0 ? 1 : 0 ) ),
labelSource.randomAccess() );
for ( final LongType t : sphere )
t.set( getValue() );
dirtyLabelsInterval.touch( accessBoxExtendedLabels.createAccessInterval() );
}
示例3: createAccumulateProjector
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Override
public AccumulateProjectorCompositeARGB createAccumulateProjector(
ArrayList< VolatileProjector > sourceProjectors,
ArrayList< Source< ? > > sources,
ArrayList< ? extends RandomAccessible< ? extends ARGBType > > sourceScreenImages,
RandomAccessibleInterval< ARGBType > targetScreenImage,
int numThreads,
ExecutorService executorService )
{
return new AccumulateProjectorCompositeARGB(
sourceProjectors,
sourceScreenImages,
targetScreenImage,
numThreads,
executorService );
}
示例4: createAccumulateProjector
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Override
public VolatileProjector createAccumulateProjector(
final ArrayList< VolatileProjector > sourceProjectors,
final ArrayList< Source< ? > > sources,
final ArrayList< ? extends RandomAccessible< ? extends A > > sourceScreenImages,
final RandomAccessibleInterval< A > targetScreenImage,
final int numThreads,
final ExecutorService executorService )
{
final CompositeProjector< A > projector = new CompositeProjector< A >(
sourceProjectors,
sourceScreenImages,
targetScreenImage,
numThreads,
executorService );
final ArrayList< Composite< A, A > > activeComposites = new ArrayList< Composite< A, A > >();
for ( final Source< ? > activeSource : sources )
activeComposites.add( composites.get( activeSource ) );
projector.setComposites( activeComposites );
return projector;
}
示例5: main
import net.imglib2.RandomAccessible; //导入依赖的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() ) ) );
}
示例6: copyInterpolatedGeneric
import net.imglib2.RandomAccessible; //导入依赖的package包/类
public static <T extends NumericType< T > > void copyInterpolatedGeneric( RandomAccessible< T > from, IterableInterval< T > to, double[] offset, double scale, InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory )
{
final int n = to.numDimensions();
final double[] fromPosition = new double[ n ];
Cursor< T > cursor = to.localizingCursor();
RealRandomAccess< T > interpolator = interpolatorFactory.create( from );
while ( cursor.hasNext() )
{
final T t = cursor.next();
for ( int d = 0; d < n; ++d )
{
fromPosition[ d ] = scale * cursor.getDoublePosition( d ) + offset[ d ];
}
interpolator.setPosition( fromPosition );
t.set( interpolator.get() );
}
}
示例7: serializeWarpField
import net.imglib2.RandomAccessible; //导入依赖的package包/类
/**
* Appends serialization of this transform's offsets and warp field to the specified data string.
*
* @param data target data string.
*/
private void serializeWarpField(final StringBuilder data) {
data.append(locationOffsets[0]).append(' ').append(locationOffsets[1]).append(' ');
data.append(affineWarpField.getWidth()).append(' ').append(affineWarpField.getHeight()).append(' ');
data.append(affineWarpField.getRowCount()).append(' ').append(affineWarpField.getColumnCount()).append(' ');
final InterpolatorFactory<RealComposite<DoubleType>, RandomAccessible<RealComposite<DoubleType>>> factory =
affineWarpField.getInterpolatorFactory();
data.append(factory.getClass().getCanonicalName()).append(' ');
final double[] values = affineWarpField.getValues();
if (values.length < 64) { // skip encoding for smaller fields to simplify visual inspection and testing
data.append(NO_ENCODING);
for (final double value : values) {
data.append(' ').append(value);
}
} else {
data.append(BASE_64_ENCODING).append(' ').append(DoubleArrayConverter.encodeBase64(values));
}
}
示例8: ProcessParalellPortion
import net.imglib2.RandomAccessible; //导入依赖的package包/类
public ProcessParalellPortion(
final ImagePortion portion,
final ArrayList< RandomAccessibleInterval< T > > imgs,
final InterpolatorFactory<T, RandomAccessible< T > > interpolatorFactory,
final AffineTransform3D[] transforms,
final Img< T > fusedImg,
final BoundingBoxGUI bb )
{
this.portion = portion;
this.imgs = imgs;
this.interpolatorFactory = interpolatorFactory;
this.transforms = transforms;
this.fusedImg = fusedImg;
this.bb = bb;
this.downSampling = bb.getDownSampling();
if ( downSampling == 1 )
doDownSampling = false;
else
doDownSampling = true;
}
示例9: getAccessor
import net.imglib2.RandomAccessible; //导入依赖的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();
}
示例10: generateBlocksXY
import net.imglib2.RandomAccessible; //导入依赖的package包/类
/**
* Goes stepwise through the y-dimensions of the image data and adds cursors
* for each row to the given list. The method does not check if there is a
* y-dimensions, so this should be made sure before. you can enforce to
* create all cursors as out-of-bounds one.
*
* @param img The image to get the data and cursors from.
* @param blockList The list to put the blocks into.
* @param offset The current offset configuration. Only [0] and [1] will be changed.
* @param size
*/
protected void generateBlocksXY(RandomAccessible<T> img, List<IterableInterval<T>> blockList,
double[] offset, double[] size) {
// potentially masked image height
double height = size[1];
final double originalY = offset[1];
// go through the height in steps of block width
double y;
for ( y = psfRadius[1]; y <= height; y += psfRadius[1] ) {
offset[1] = originalY + y - psfRadius[1];
generateBlocksX(img, blockList, offset, size);
}
// check is we need to add a out of bounds strategy cursor
if (y > height) {
offset[1] = originalY + y - psfRadius[1];
generateBlocksX(img, blockList, offset, size);
}
offset[1] = originalY;
}
示例11: compute
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> input,
final RandomAccessibleInterval<T> output)
{
// input may potentially be translated
final long[] translation = new long[input.numDimensions()];
input.min(translation);
final IntervalView<T> tmpInterval = Views.interval(Views.translate(
(RandomAccessible<T>) tmpCreator.calculate(input), translation), output);
gauss1.compute(input, tmpInterval);
gauss2.compute(input, output);
// TODO: Match the Subtract Op in initialize() once we have BinaryOp
ops().run(Ops.Math.Subtract.class, output, output, tmpInterval);
}
示例12: compute
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Override
public void compute(final RandomAccessibleInterval<T> input,
final RandomAccessibleInterval<T> output)
{
if (outOfBounds == null) {
outOfBounds = new OutOfBoundsMirrorFactory<>(Boundary.SINGLE);
}
final RandomAccessible<FloatType> eIn = //
(RandomAccessible) Views.extend(input, outOfBounds);
try {
SeparableSymmetricConvolution.convolve(Gauss3.halfkernels(sigmas), eIn,
output, threads.getExecutorService());
}
catch (final IncompatibleTypeException e) {
throw new RuntimeException(e);
}
}
示例13: defaultHyperSliceTest
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Test
public void defaultHyperSliceTest() {
final Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10, 10 },
new DoubleType());
final MixedTransformView<DoubleType> il2 = Views.hyperSlice((RandomAccessible<DoubleType>) img, 1, 8);
final MixedTransformView<DoubleType> opr = ops.transform().hyperSliceView(deinterval(img), 1, 8);
for (int i = 0; i < il2.getTransformToSource().getMatrix().length; i++) {
for (int j = 0; j < il2.getTransformToSource().getMatrix()[i].length; j++) {
assertEquals(il2.getTransformToSource().getMatrix()[i][j], opr.getTransformToSource().getMatrix()[i][j],
1e-10);
}
}
}
示例14: defaultCollapseNumericTest
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Test
public void defaultCollapseNumericTest() {
Img<NativeARGBDoubleType> img = new ArrayImgFactory<NativeARGBDoubleType>().create(new int[] { 10, 10 },
new NativeARGBDoubleType());
CompositeIntervalView<NativeARGBDoubleType, NumericComposite<NativeARGBDoubleType>> il2 = Views
.collapseNumeric((RandomAccessibleInterval<NativeARGBDoubleType>) img);
CompositeIntervalView<NativeARGBDoubleType, NumericComposite<NativeARGBDoubleType>> opr = ops.transform()
.collapseNumericView((RandomAccessibleInterval<NativeARGBDoubleType>) img);
assertEquals(il2.numDimensions(), opr.numDimensions());
CompositeView<NativeARGBDoubleType, NumericComposite<NativeARGBDoubleType>> il2_2 = Views
.collapseNumeric((RandomAccessible<NativeARGBDoubleType>) img, 1);
CompositeView<NativeARGBDoubleType, NumericComposite<NativeARGBDoubleType>> opr_2 = ops.transform()
.collapseNumericView((RandomAccessible<NativeARGBDoubleType>) img, 1);
assertEquals(il2_2.numDimensions(), opr_2.numDimensions());
}
示例15: addDimensionTest
import net.imglib2.RandomAccessible; //导入依赖的package包/类
@Test
public void addDimensionTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.addDimension((RandomAccessible<DoubleType>)img);
MixedTransformView<DoubleType> opr = ops.transform().addDimensionView((RandomAccessible<DoubleType>)img);
assertEquals(il2.numDimensions(), opr.numDimensions());
boolean[] il2Transform = new boolean[3];
boolean[] oprTransform = new boolean[3];
il2.getTransformToSource().getComponentZero(il2Transform);
opr.getTransformToSource().getComponentZero(oprTransform);
for (int i = 0; i < il2Transform.length; i++) {
assertEquals(il2Transform[i], oprTransform[i]);
}
}