@Override public ExtendedRandomAccessibleInterval<T, F> calculate(F input) { return Views.extendBorder(input); }
public static <T> RandomAccessible<T> deinterval( RandomAccessibleInterval<T> input) { return Views.extendBorder(input); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the border value. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandBorder( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendBorder( source ), Intervals.expand( source, border ) ); }
/** * Expand a RandomAccessibleInterval as specified by border. source will be * extended with the border value. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandBorder( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendBorder( source ), Intervals.expand( source, border ) ); }
private RandomAccessible<BitType> constantImg(final int numDims) { final long[] dims = new long[numDims]; Arrays.fill(dims, 1); final ArrayImg<BitType, LongArray> bitImg = ArrayImgs.bits(dims); bitImg.setLinkedType(new BitType(bitImg)); bitImg.cursor().next().set(true); return Views.extendBorder(bitImg); }
public LinearIntensityMap( final RandomAccessibleInterval< T > source, final InterpolatorFactory< RealComposite< T >, RandomAccessible< RealComposite< T > > > interpolatorFactory ) { this.interpolatorFactory = interpolatorFactory; final CompositeIntervalView< T, RealComposite< T > > collapsedSource = Views.collapseReal( source ); dimensions = new FinalInterval( collapsedSource ); final double[] shift = new double[ dimensions.numDimensions() ]; for ( int d = 0; d < shift.length; ++d ) shift[ d ] = 0.5; translation = new Translation( shift ); final RandomAccessible< RealComposite< T > > extendedCollapsedSource = Views.extendBorder( collapsedSource ); coefficients = Views.interpolate( extendedCollapsedSource, interpolatorFactory ); }
/** * Removes leading 0s from integral image after composite creation. * * @param input Input RAI (can be a RAI of Composite) * @return An extended and cropped version of input */ private <T> RandomAccessibleInterval<T> removeLeadingZeros( final RandomAccessibleInterval<T> input) { // Remove 0s from integralImg by shifting its interval by +1 final long[] min = Intervals.minAsLongArray(input); final long[] max = Intervals.maxAsLongArray(input); for (int d = 0; d < input.numDimensions(); ++d) { int correctedSpan = getShape().getSpan() - 1; min[d] += (1 + correctedSpan); max[d] -= correctedSpan; } // Define the Interval on the infinite random accessibles final FinalInterval interval = new FinalInterval(min, max); final RandomAccessibleInterval<T> extendedImg = Views.offsetInterval(Views .extendBorder(input), interval); return extendedImg; }
public static final ImagePlus makeEmptyImagePlus(final int width, final int height, final int nslices, final int nframes, final double[] calibration) { final RandomAccessible< UnsignedByteType > randomAccessible = Views.extendBorder( ArrayImgs.unsignedBytes( new long[] { 1, 1, 1, 1 } ) ); final Interval interval = new FinalInterval( width, height, nslices, nframes ); final RandomAccessibleInterval< UnsignedByteType > view = Views.interval( randomAccessible, interval ); final ImagePlus imp = ImageJFunctions.wrap(view, "blank"); imp.getCalibration().pixelWidth = calibration[0]; imp.getCalibration().pixelHeight = calibration[1]; imp.getCalibration().pixelDepth = calibration[2]; imp.setDimensions(1, nslices, nframes); imp.setOpenAsHyperStack(true); return imp; }
public static final ImagePlus makeEmptyImagePlus(final int width, final int height, final int nslices, final int nframes, final double[] calibration) { final RandomAccessible< UnsignedByteType > randomAccessible = Views.extendBorder( ArrayImgs.unsignedBytes( new long[] { 1, 1, 1, 1 } ) ); final Interval interval = new FinalInterval( width, height, nslices, nframes ); final RandomAccessibleInterval< UnsignedByteType > view = Views.interval( randomAccessible, interval ); final ImagePlus imp = ImageJFunctions.wrap(view, "blank"); imp.getCalibration().pixelWidth = calibration[0]; imp.getCalibration().pixelHeight = calibration[1]; imp.getCalibration().pixelDepth = calibration[2]; imp.setDimensions(1, nslices, nframes); imp.setOpenAsHyperStack(true); return imp; }
static class LoopBackImageLoader extends Hdf5ImageLoader { private LoopBackImageLoader( final IHDF5Reader existingHdf5Reader, final AbstractSequenceDescription< ?, ?, ? > sequenceDescription ) { super( null, existingHdf5Reader, null, sequenceDescription, false ); } static LoopBackImageLoader create( final IHDF5Reader existingHdf5Reader, final int timepointIdPartition, final int setupIdPartition, final Dimensions imageDimensions ) { final HashMap< Integer, TimePoint > timepoints = new HashMap<>(); timepoints.put( timepointIdPartition, new TimePoint( timepointIdPartition ) ); final HashMap< Integer, BasicViewSetup > setups = new HashMap<>(); setups.put( setupIdPartition, new BasicViewSetup( setupIdPartition, null, imageDimensions, null ) ); final SequenceDescriptionMinimal seq = new SequenceDescriptionMinimal( new TimePoints( timepoints ), setups, null, null ); return new LoopBackImageLoader( existingHdf5Reader, seq ); } }
return new FlatFieldCorrectedRandomAccessibleInterval<>(outputType, sourceImg, Views.interval( constantBright, sourceImg ), Views.interval( Views.extendBorder( darkImg ), intervalDark ) ); return new FlatFieldCorrectedRandomAccessibleInterval<>(outputType, sourceImg, Views.interval( Views.extendBorder( brightImg ), intervalBright ), Views.interval( constantDark, sourceImg ) ); return new FlatFieldCorrectedRandomAccessibleInterval<>(outputType, sourceImg, Views.interval( Views.extendBorder( brightImg ), intervalBright ), Views.interval( Views.extendBorder( darkImg ), intervalDark ) );
/** * {@link RandomAccessibleInterval} with same sice as target is returned * * @param src * {@link RandomAccessibleInterval} to be adjusted * @param target * {@link Interval} describing the resulting sizes * @return Adjusted {@link RandomAccessibleInterval} */ public static <T> RandomAccessibleInterval<T> synchronizeDimensionality( final RandomAccessibleInterval<T> src, final Interval target) { RandomAccessibleInterval<T> res = src; // Check direction of conversion if (intervalEquals(src, target)) return res; // adjust dimensions if (res.numDimensions() < target.numDimensions()) { for (int d = res.numDimensions(); d < target.numDimensions(); d++) { res = Views.addDimension(res, target.min(d), target.max(d)); } } else { for (int d = res.numDimensions() - 1; d >= target.numDimensions(); --d) res = Views.hyperSlice(res, d, 0); } long[] resDims = new long[res.numDimensions()]; res.dimensions(resDims); return Views.interval(Views.extendBorder(res), target); }
/** * {@link RandomAccessibleInterval} with same sice as target is returned * * @param src * {@link RandomAccessibleInterval} to be adjusted * @param target * {@link Interval} describing the resulting sizes * @return Adjusted {@link RandomAccessibleInterval} */ public static <T> RandomAccessibleInterval<T> synchronizeDimensionality( final RandomAccessibleInterval<T> src, final Interval target) { RandomAccessibleInterval<T> res = src; // Check direction of conversion if (intervalEquals(src, target)) return res; // adjust dimensions if (res.numDimensions() < target.numDimensions()) { for (int d = res.numDimensions(); d < target.numDimensions(); d++) { res = Views.addDimension(res, target.min(d), target.max(d)); } } else { for (int d = res.numDimensions() - 1; d >= target.numDimensions(); --d) res = Views.hyperSlice(res, d, 0); } long[] resDims = new long[res.numDimensions()]; res.dimensions(resDims); return Views.interval(Views.extendBorder(res), target); }
final RandomAccessible<BitType> ra1 = Views.extendBorder(buffer); final RandomAccessible<BitType> ra2 = Views.extendBorder(output); RandomAccessible<BitType> currRa = Views.extendBorder(input);
HessianMatrix.calculateMatrix(Views.extendBorder(input), gaussian, gradient, hessian, new OutOfBoundsBorderFactory<>(), nThreads, es, sigma);
croppedSourceImg = Views.zeroMin( Views.interval( Views.extendBorder( sourceImg ), sourceInterval ) ); croppedSourceTransform.set( 1, 0, 0, sourceInterval.min( 0 ),
final RandomAccess< T > randomAccess = Views.extendBorder( input ).randomAccess();
@Test public void extendBorderTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); OutOfBounds<DoubleType> il2 = Views.extendBorder(img).randomAccess(); OutOfBounds<DoubleType> opr = ops.transform().extendBorderView(img).randomAccess(); il2.setPosition(new int[] { -1, -1 }); opr.setPosition(new int[] { -1, -1 }); assertEquals(il2.get().get(), opr.get().get(), 1e-10); il2.setPosition(new int[] { 11, 11 }); opr.setPosition(new int[] { 11, 11 }); assertEquals(il2.get().get(), opr.get().get(), 1e-10); }
Views.extendBorder(Views.interval(resRndAccessible, target)), target);
Views.extendBorder(Views.interval(resRndAccessible, target)), target);