public void setImg( final RandomAccessibleInterval< R > img ) { this.img = Views.extendMirrorSingle( img ); this.imgInterval = img; this.fftImg = null; }
public void setImg( final RandomAccessibleInterval< R > img ) { this.img = Views.extendMirrorSingle( img ); this.imgInterval = img; this.fftImg = null; }
@Override public ExtendedRandomAccessibleInterval<T, F> calculate(F input) { return Views.extendMirrorSingle(input); } }
public void setImg( final RandomAccessibleInterval< R > img ) { this.img = Views.extendMirrorSingle( img ); this.imgInterval = img; this.fftImg = null; }
public ExtendMirrorSingle(final RandomAccessibleInterval<T> img) { super(Views.interval(Views.extendMirrorSingle(img), img)); }
public static enum ExtremaType { /** * Bright blobs on dark background. */ MINIMA, /** * Dark blobs on bright background. */ MAXIMA }
/** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are not * repeated. Note that this requires that all dimensions of the source (F * source) must be > 1. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorSingle( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorSingle( source ), Intervals.expand( source, border ) ); }
/** * Expand a RandomAccessibleInterval as specified by border. Out of bounds * pixels will be sampled by mirroring source. Boundary pixels are not * repeated. Note that this requires that all dimensions of the source (F * source) must be > 1. * * @param source * the interval to expand. * @return Expansion of the {@link RandomAccessibleInterval} source as * specified by border. */ public static < T > IntervalView< T > expandMirrorSingle( final RandomAccessibleInterval< T > source, final long... border ) { return interval( extendMirrorSingle( source ), Intervals.expand( source, border ) ); }
public static double[] computeCenter( final Img< FloatType > i, final double threshold ) throws IncompatibleTypeException { final Img<FloatType> copy = i.copy(); Gauss3.gauss( 2, Views.extendMirrorSingle( copy ), copy ); return centerofmass( copy, threshold ); }
public ImageInterpolation( final Img< T > image, final InterpolatorFactory< T, RandomAccessible< T > > interpolatorFactory, final boolean mirror ) { this.image = image; this.interpolatorFactory = interpolatorFactory; if ( mirror ) this.interpolated = Views.interpolate( Views.extendMirrorSingle( image ), interpolatorFactory ); else this.interpolated = Views.interpolate( Views.extendZero( image ), interpolatorFactory ); }
/** * Compute a Fourier space based convolution * The image will be extended by mirroring with single boundary, the kernel will be zero-padded. * * @param img - the image * @param kernel - the convolution kernel * @param output - the output * @param factory - the {@link ImgFactory} to create the fourier transforms */ public FFTConvolution( final RandomAccessibleInterval< R > img, final RandomAccessibleInterval< R > kernel, final RandomAccessibleInterval< R > output, final ImgFactory< ComplexFloatType > factory ) { this ( Views.extendMirrorSingle( img ), img, Views.extendValue( kernel, Util.getTypeFromInterval( kernel ).createVariable() ), kernel, output, factory ); }
/** * Compute a Fourier space based convolution The image will be extended by * mirroring with single boundary, the kernel will be zero-padded. * * @param img * - the image * @param kernel * - the convolution kernel * @param output * - the output * @param factory * - the {@link ImgFactory} to create the fourier transforms * @param service * - service providing threads for multi-threading */ public FFTConvolution( final RandomAccessibleInterval< R > img, final RandomAccessibleInterval< R > kernel, final RandomAccessibleInterval< R > output, final ImgFactory< ComplexFloatType > factory, final ExecutorService service ) { this( Views.extendMirrorSingle( img ), img, Views.extendValue( kernel, Util.getTypeFromInterval( kernel ).createVariable() ), kernel, output, factory, service ); }
public static Img< FloatType > extractLI( final Img< FloatType > img, final long[] dim, final double[] center ) { final Img< FloatType > psf = new ArrayImgFactory< FloatType >().create( dim, new FloatType() ); final ArrayList< RealLocalizable > locations = new ArrayList<>(); locations.add( new RealPoint( center ) ); //locations.add( new RealPoint( new double[] { i.dimension( 0 ) / 2, i.dimension( 1 ) / 2, i.dimension( 2 ) / 2 } ) ); final RealRandomAccessible< FloatType > rra = Views.interpolate( Views.extendMirrorSingle( img ), new NLinearInterpolatorFactory<>() ); PSFExtraction.extractPSFLocal( rra, locations, psf ); return psf; }
public static Img< FloatType > extractNN( final Img< FloatType > img, final long[] dim, final double[] center ) { final Img< FloatType > psf = new ArrayImgFactory< FloatType >().create( dim, new FloatType() ); final ArrayList< RealLocalizable > locations = new ArrayList<>(); locations.add( new RealPoint( center ) ); //locations.add( new RealPoint( new double[] { i.dimension( 0 ) / 2, i.dimension( 1 ) / 2, i.dimension( 2 ) / 2 } ) ); final RealRandomAccessible< FloatType > rra = Views.interpolate( Views.extendMirrorSingle( img ), new NearestNeighborInterpolatorFactory<>()); PSFExtraction.extractPSFLocal( rra, locations, psf ); return psf; }
@Override public RandomAccessibleInterval<T> calculate(RandomAccessibleInterval<T> input) { final long[] newDims = Intervals.dimensionsAsLongArray(in()); for (int i = 0; i < Math.min(scaleFactors.length, in().numDimensions()); i++) { newDims[i] = Math.round(in().dimension(i) * scaleFactors[i]); } IntervalView<T> interval = Views.interval(Views.raster(RealViews.affineReal( Views.interpolate(Views.extendMirrorSingle(input), interpolator), new Scale(scaleFactors))), new FinalInterval(newDims)); return interval; }
/** * @see MaxFilterOp * @see DefaultMaxFilter */ @Test public void testMaxFilter() { ops.run(MaxFilterOp.class, out, in, shape, oobFactory); byte max = Byte.MIN_VALUE; NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in)); for (ByteType t : neighborhoods.firstElement()) { max = (byte) Math.max(t.getInteger(), max); } assertEquals(out.firstElement().get(), max); }
/** * @see MinFilterOp * @see DefaultMinFilter */ @Test public void testMinFilter() { ops.run(MinFilterOp.class, out, in, shape, oobFactory); byte min = Byte.MAX_VALUE; NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in)); for (ByteType t : neighborhoods.firstElement()) { min = (byte) Math.min(t.getInteger(), min); } assertEquals(min, out.firstElement().get()); }
/** * @see MeanFilterOp * @see DefaultMeanFilter */ @Test public void testMeanFilter() { ops.run(MeanFilterOp.class, out, in, shape, oobFactory); double sum = 0.0; NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in)); for (ByteType t : neighborhoods.firstElement()) { sum += t.getRealDouble(); } assertEquals(Util.round(sum / 9.0), out.firstElement().get()); }
/** * @see VarianceFilterOp * @see DefaultVarianceFilter */ @Test public void testVarianceFilter() { ops.run(VarianceFilterOp.class, out, in, shape, oobFactory); double sum = 0.0; double sumSq = 0.0; NeighborhoodsIterableInterval<ByteType> neighborhoods = shape.neighborhoods(Views.interval(Views.extendMirrorSingle(in), in)); for (ByteType t : neighborhoods.firstElement()) { sum += t.getRealDouble(); sumSq += t.getRealDouble()*t.getRealDouble(); } assertEquals((byte)Util.round((sumSq - (sum * sum / 9)) / 8), out.firstElement().get()); }
@Test public void extendMirrorSingleTest() { Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType()); OutOfBounds<DoubleType> il2 = Views.extendMirrorSingle(img).randomAccess(); OutOfBounds<DoubleType> opr = ops.transform().extendMirrorSingleView(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); }