@Override public IntervalView<T> calculate(RandomAccessibleInterval<T> input) { return Views.addDimension(input, minOfNewDim, maxOfNewDim); }
@Override public MixedTransformView<T> calculate(RandomAccessible<T> input) { return Views.addDimension(input); }
protected RandomAccessibleInterval< FloatType > getOrCreateDarkImgDownsampled(ViewId vId, int[] downsamplingFactors) { ArrayList< Integer > dsFactorList = new ArrayList< Integer >(); for ( int i : downsamplingFactors ) dsFactorList.add( i ); final ValuePair< File, List< Integer > > key = new ValuePair<>( fileMap.get( vId ).getB(), dsFactorList ); if ( !dsRaiMap.containsKey( key ) ) { final RandomAccessibleInterval< FloatType > darkImg = getDarkImg( vId ); if ( darkImg == null ) return null; // NB: we add a singleton z-dimension here for downsampleHDF5 to // work final RandomAccessibleInterval< FloatType > downsampled = downsampleHDF5( Views.addDimension( darkImg, 0, 0 ), downsamplingFactors ); dsRaiMap.put( key, downsampled ); } return dsRaiMap.get( key ); }
protected RandomAccessibleInterval< FloatType > getOrCreateBrightImgDownsampled(ViewId vId, int[] downsamplingFactors) { ArrayList< Integer > dsFactorList = new ArrayList< Integer >(); for ( int i : downsamplingFactors ) dsFactorList.add( i ); final ValuePair< File, List< Integer > > key = new ValuePair<>( fileMap.get( vId ).getA(), dsFactorList ); if ( !dsRaiMap.containsKey( key ) ) { final RandomAccessibleInterval< FloatType > brightImg = getBrightImg( vId ); if ( brightImg == null ) return null; // NB: we add a singleton z-dimension here for downsampleHDF5 to // work final RandomAccessibleInterval< FloatType > downsampled = downsampleHDF5( Views.addDimension( brightImg, 0, 0 ), downsamplingFactors ); dsRaiMap.put( key, downsampled ); } return dsRaiMap.get( key ); }
sourceStacks.set( i, Views.addDimension( sourceStacks.get( i ), 0, 0 ) );
/** * Create view which adds a dimension to the source * {@link RandomAccessibleInterval}. The {@link Interval} boundaries in the * additional dimension are set to the specified values. * * The additional dimension is the last dimension. For example, an XYZ view * is created for an XY source. When accessing an XYZ sample in the view, * the final coordinate is discarded and the source XY sample is accessed. * * @param interval * the source * @param minOfNewDim * Interval min in the additional dimension. * @param maxOfNewDim * Interval max in the additional dimension. */ public static < T > IntervalView< T > addDimension( final RandomAccessibleInterval< T > interval, final long minOfNewDim, final long maxOfNewDim ) { final int m = interval.numDimensions(); final long[] min = new long[ m + 1 ]; final long[] max = new long[ m + 1 ]; for ( int d = 0; d < m; ++d ) { min[ d ] = interval.min( d ); max[ d ] = interval.max( d ); } min[ m ] = minOfNewDim; max[ m ] = maxOfNewDim; return Views.interval( Views.addDimension( interval ), min, max ); }
@Override public void run() { // parse the spacing, and scales strings. spacing = checkDimensions(spacingString, input.numDimensions(), "Spacings"); scales = Arrays.stream(scaleString.split(regex)).mapToInt(Integer::parseInt) .toArray(); Dimensions resultDims = Views.addDimension(input, 0, scales.length - 1); // create output image, potentially-filtered input result = opService.create().img(resultDims, new FloatType()); for (int s = 0; s < scales.length; s++) { // Determine whether or not the user would like to apply the gaussian // beforehand and do it. RandomAccessibleInterval<T> vesselnessInput = doGauss ? opService.filter() .gauss(input, scales[s]) : input; IntervalView<FloatType> scaleResult = Views.hyperSlice(result, result .numDimensions() - 1, s); opService.filter().frangiVesselness(scaleResult, vesselnessInput, spacing, scales[s]); } } }
/** * Create view which adds a dimension to the source * {@link RandomAccessibleInterval}. The {@link Interval} boundaries in the * additional dimension are set to the specified values. * * The additional dimension is the last dimension. For example, an XYZ view * is created for an XY source. When accessing an XYZ sample in the view, * the final coordinate is discarded and the source XY sample is accessed. * * @param interval * the source * @param minOfNewDim * Interval min in the additional dimension. * @param maxOfNewDim * Interval max in the additional dimension. */ public static < T > IntervalView< T > addDimension( final RandomAccessibleInterval< T > interval, final long minOfNewDim, final long maxOfNewDim ) { final int m = interval.numDimensions(); final long[] min = new long[ m + 1 ]; final long[] max = new long[ m + 1 ]; for ( int d = 0; d < m; ++d ) { min[ d ] = interval.min( d ); max[ d ] = interval.max( d ); } min[ m ] = minOfNewDim; max[ m ] = maxOfNewDim; return Views.interval( Views.addDimension( interval ), min, max ); }
interval = new FinalInterval( min, max ); for ( int i = 0; i < sourceStacks.size(); ++i ) sourceStacks.set( i, Views.addDimension( sourceStacks.get( i ) ) );
( RandomAccessible< T > ) Views.addDimension( source ), Views.interval( Views.addDimension( target ), new FinalInterval( target.dimension( 0 ), 1 ) ), d, 0 );
( RandomAccessible< T > ) Views.addDimension( source ), Views.interval( Views.addDimension( target ), new FinalInterval( target.dimension( 0 ), 1 ) ), 0, weights[ 0 ] );
( RandomAccessible< T > ) Views.addDimension( source ), Views.interval( Views.addDimension( target ), new FinalInterval( target.dimension( 0 ), 1 ) ), 0, weights[ 0 ],
/** * * Switch for calling convenience method with pre-defined distances. * */ public static enum DISTANCE_TYPE { /** * Squared Euclidian distance using {@link EuclidianDistanceIsotropic} or * {@link EuclidianDistanceAnisotropic}. */ EUCLIDIAN, /** * L1 distance using special case implementation. */ L1 }
/** * {@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); }
@Test public void addDimensionMinMaxTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); int max = 20; int min = 0; IntervalView<DoubleType> il2 = Views.addDimension(img, min, max); IntervalView<DoubleType> opr = ops.transform().addDimensionView(img, min, max); assertEquals(il2.numDimensions(), opr.numDimensions(), 0.0); for (int i = 0; i < il2.numDimensions(); i++) { assertEquals(il2.dimension(i), opr.dimension(i), 0.0); } } }
RandomAccessible<T> expandedKernelA = Views.addDimension(kernelA); RandomAccessible<T> expandedKernelB = Views.addDimension(kernelB); for (int i = 0; i < in().numDimensions() - 3; i++) { expandedKernelA = Views.addDimension(expandedKernelA); expandedKernelB = Views.addDimension(expandedKernelB);
@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]); } }
for (final AxisType type : missing) { final int idx = targetSpace.getAxisIndex(type); res = Views.addDimension(res, target.min(idx), target.max(idx)); resSpace.setAxis(type, i++);
for (final AxisType type : missing) { final int idx = targetSpace.dimensionIndex(type); res = Views.addDimension(res, target.min(idx), target.max(idx)); resSpace.setAxis(new DefaultLinearAxis(type), i++);