public PointSpreadFunction( final File xmlBasePath, final String file, final Img< FloatType > img ) { this.xmlBasePath = xmlBasePath; this.file = file; if ( img != null ) this.img = img.copy(); // avoid changes to the PSF if an actual image is provided this.modified = true; // not initialized from disc, needs to be saved }
@Override public Img<T> copy() { return img.copy(); }
@Override public ImgPlus<T> copy() { return new ImgPlus<>(img.copy(), this); }
@Override public DiscreteFrequencyDistribution copy() { return new DiscreteFrequencyDistribution( counts.copy() ); }
@Override public DiscreteFrequencyDistribution copy() { return new DiscreteFrequencyDistribution( counts.copy() ); }
public Img< FloatType > getPSFCopy() { if ( img == null ) img = IOFunctions.openAs32Bit( new File( new File( xmlBasePath, subDir ), file ), new ArrayImgFactory<>() ); return img.copy(); }
protected void loadFileIfNecessary(File file) { if (raiMap.containsKey( file )) return; final ImagePlus imp = IJ.openImage( file.getAbsolutePath() ); final RandomAccessibleInterval< FloatType > img = ImageJFunctions.convertFloat( imp ).copy(); raiMap.put( file, img ); }
double computeAccelerationFactor(RandomAccessibleInterval<T> yk_iterated) { // gk=StaticFunctions.Subtract(yk_iterated, yk_prediction); Subtract(yk_iterated, yk_prediction, gk); if (gkm1 != null) { double numerator = DotProduct(gk, gkm1); double denominator = DotProduct(gkm1, gkm1); gkm1 = gk.copy(); return numerator / denominator; } gkm1 = gk.copy(); return 0.0; }
@SuppressWarnings({ "rawtypes", "unchecked" }) private static final <R extends NumericType<R>> Img<R> process(final IterableInterval<R> img) { if (img instanceof Img) { return ((Img<R>)img).copy(); } if (img.firstElement() instanceof NativeType<?>) { return copyAsArrayImg((IterableInterval)img); } throw new IllegalArgumentException("Could not duplicate image of class " + img.getClass() + " with type " + img.firstElement().getClass()); } }
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 ); }
@Override public HyperSliceImgPlus<T> copy() { return new HyperSliceImgPlus<T>(new ImgPlus<T>(getImg().copy(), this), targetDimension, dimensionPosition); }
@Override public SCIFIOImgPlus<T> copy() { final SCIFIOImgPlus<T> copy = new SCIFIOImgPlus<>(getImg().copy(), this); copy.setMetadata(getMetadata()); return copy; }
@Override public HyperSliceImgPlus<T> copy() { return new HyperSliceImgPlus<T>(new ImgPlus<T>(getImg().copy(), this), targetDimension, dimensionPosition); }
@Test public void pixelWiseTestThreadedMapperInplace() { ops.run(MapIIInplaceParallel.class, in.copy(), addConstantInplace); } }
public static void main( final String[] args ) { new ImageJ(); ImagePlus imp = new ImagePlus( "/Users/preibischs/workspace/TestLucyRichardson/src/resources/dros-1.tif" ); Img< FloatType > img = ImageJFunctions.convertFloat( imp ); ImageJFunctions.show( img.copy() ); ImageJFunctions.show( computeLazyMinFilter( img, 5 ) ); } }
public void testListErode() { final List<Shape> shapes = new ArrayList<>(); shapes.add(new DiamondShape(1)); shapes.add(new DiamondShape(1)); shapes.add(new RectangleShape(1, false)); shapes.add(new HorizontalLineShape(2, 1, false)); final Img<ByteType> out2 = in.copy(); Erosion.erode(Views.extendValue(in, new ByteType((byte) -128)), out2, shapes, 1); @SuppressWarnings("unchecked") final IterableInterval<ByteType> out1 = (IterableInterval<ByteType>) ops .run(ListErode.class, IterableInterval.class, in, shapes, false); assertIterationsEqual(out1, out2); }
@Test public void testIIInplaceParallel() { final Img<ByteType> arg = generateByteArrayTestImg(true, 10, 10); final Img<ByteType> argCopy = arg.copy(); sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class, new ByteType((byte) 1)); ops.run(MapIIInplaceParallel.class, argCopy, sub); assertImgSubOneEquals(arg, argCopy); }
@Test public void testIIInplaceParallelCellImg() { final Img<ByteType> arg = generateByteTestCellImg(true, 40, 20); final Img<ByteType> argCopy = arg.copy(); sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class, new ByteType((byte) 1)); ops.run(MapIIInplaceParallel.class, argCopy, sub); assertImgSubOneEquals(arg, argCopy); }
@Test public void testIterableInplace() { final Img<ByteType> arg = generateByteArrayTestImg(true, 10, 10); final Img<ByteType> argCopy = arg.copy(); sub = Inplaces.unary(ops, Ops.Math.Subtract.class, ByteType.class, new ByteType((byte) 1)); ops.run(MapIterableInplace.class, argCopy, sub); assertImgSubOneEquals(arg, argCopy); }