@Override public int numDimensions() { return counts.numDimensions(); }
/** * Instantiate a 2D gaussian peak fitter that will operate on the given image. * It is important that the image has a 0 background for this class to * operate properly. */ public GaussianPeakFitterND(final Img<T> image) { this.image = image; this.ndims = image.numDimensions(); }
@Override public int numDimensions() { return counts.numDimensions(); }
public PickImagePeaks(final Img<T> inputImage) { image = inputImage; pTime = 0; peakLocList = new ArrayList<long[]>(); peakImage = null; suppressAxis = new double[inputImage.numDimensions()]; Arrays.fill(suppressAxis, 0); suppressSum = 0; }
public FloydSteinbergDithering( final Img<T> img, final float ditheringThreshold ) { this.img = img; this.dim = Util.intervalDimensions(img); this.tmp1 = new long[img.numDimensions()]; this.tmp2 = new long[img.numDimensions()]; this.errorDiffusionKernel = createErrorDiffusionKernel( img.numDimensions() ); this.ditheringThreshold = ditheringThreshold; }
public void setDownSamplingFactor( final float factor ) { newSize = new long[ input.numDimensions() ]; scaling = new float[ input.numDimensions() ]; for ( int d = 0; d < input.numDimensions(); ++d ) { newSize[ d ] = Util.round( input.dimension(d) * factor ); scaling[ d ] = 1.0f / factor; } } public void setNewSize( final long[] newSize ) { this.newSize = newSize.clone(); }
protected static int[] getMaxDim( final Img<?> image1, final Img<?> image2 ) { final int[] maxDim = new int[ image1.numDimensions() ]; for ( int d = 0; d < image1.numDimensions(); ++d ) maxDim[ d ] = (int) Math.max( image1.dimension( d ), image2.dimension( d ) ); return maxDim; }
/** Calls the DifferenceOfGaussianOld constructor with the given sigmas copied into double[] arrays, * one entry per {@param img} dimension. */ public DifferenceOfGaussianOld( final Img<A> img, final ImgFactory<FloatType> factory, final OutOfBoundsFactory<FloatType, RandomAccessibleInterval<FloatType>> outOfBoundsFactory, final double sigma1, final double sigma2, final double minPeakValue, final double normalizationFactor ) { this( img, factory, outOfBoundsFactory, asArray(img.numDimensions(), sigma1), asArray(img.numDimensions(), sigma2), minPeakValue, normalizationFactor ); }
/** * @param image - The {@link Img} to mirror * @param dimension - The axis to mirror (e.g. 0->x-Axis->horizontally, 1->y-axis->vertically) */ public MirrorImage( final Img<T> image, final int dimension ) { this.image = image; this.dimension = dimension; this.numDimensions = image.numDimensions(); setNumThreads(); }
static private final long[] asDimArray(final Img<?> img, final Number scale) { final long[] dim = new long[img.numDimensions()]; final double s = scale.doubleValue(); for (int i=0; i<dim.length; i++) { dim[i] = (int)((img.dimension(i) * s) + 0.5); } return dim; }
static private final long[] dimensions(final Img<?> img) { final long[] ds = new long[img.numDimensions()]; for (int d=0; d<ds.length; ++d) { ds[d] = img.dimension(d) + 1; } return ds; }
/** Calls the DifferenceOfGaussian constructor with the given sigmas copied into double[] arrays, * one entry per {@param img} dimension. */ public DifferenceOfGaussian( final Img<A> img, final ImgFactory<A> factory, final OutOfBoundsFactory<A, RandomAccessibleInterval<A>> outOfBoundsFactory, final double sigma1, final double sigma2, final double minPeakValue, final double normalizationFactor ) { this( img, factory, outOfBoundsFactory, asArray(img.numDimensions(), sigma1), asArray(img.numDimensions(), sigma2), minPeakValue, normalizationFactor ); }
public SubpixelLocalization( final Img<T> laPlacian, final List<DifferenceOfGaussianPeak<T>> peaks ) { setNumThreads(); this.laPlacian = laPlacian; this.peaks = peaks; this.allowedToMoveInDim = new boolean[ laPlacian.numDimensions() ]; // principally one can move in any dimension for ( int d = 0; d < allowedToMoveInDim.length; ++d ) allowedToMoveInDim[ d ] = true; this.doubleArrayFactory = new ArrayImgFactory<DoubleType>(); }
/** The dimensions of the integral image are always +1 from the integrated image. */ protected static final boolean isIntegerDivision(Img<?> integralImg, Img<?> scaled) { for ( int d = 0; d < scaled.numDimensions(); ++d ) if ( 0 != (integralImg.dimension( d ) -1) % scaled.dimension( d ) ) return false; return true; }
public Bandpass( final Img<T> img, final int beginRadius, final int endRadius ) { this.img = img; this.inPlace = false; this.bandPass = true; this.beginRadius = beginRadius; this.endRadius = endRadius; this.origin = new long[ img.numDimensions() ]; this.origin[ 0 ] = img.dimension( 0 ) - 1; for ( int d = 1; d < this.origin.length; ++d ) origin[ d ] = img.dimension( d ) / 2; }
public static < T extends RealType< T > > void removeMinProjections( final Img< T > psf ) { for ( int d = 0; d < psf.numDimensions(); ++d ) { final Img< T > minProjection = PSFCombination.computeProjection( psf, d, false ); subtractProjection( psf, minProjection, d ); } }
/** * Calculate an image signature * * The image signature are 1st and 2nd order moments of the intensity and * the coordinates. */ protected < T extends RealType< T >> float[] signature( final Img< T > image ) { final float[] result = new float[ ( image.numDimensions() + 1 ) * 2 ]; signature( image, result ); return result; }
public static < T extends RealType< T > > Img< T > computeMaxProjectionPSF( final Img< T > avg ) { int minDim = -1; long minDimSize = Long.MAX_VALUE; for ( int d = 0; d < avg.numDimensions(); ++d ) if ( avg.dimension( d ) < minDimSize ) { minDimSize = avg.dimension( d ); minDim = d; } return computeProjection( avg, minDim, true ); }
private void placeSphereInCenter(Img<FloatType> img) { final Point center = new Point(img.numDimensions()); for (int d = 0; d < img.numDimensions(); d++) center.setPosition(img.dimension(d) / 2, d); HyperSphere<FloatType> hyperSphere = new HyperSphere<>(img, center, 2); for (final FloatType value : hyperSphere) { value.setReal(1); } }
private ImgPlus<UnsignedByteType> splitColorChannels(ImgPlus<ARGBType> input) { Img<ARGBType> colored = input.getImg(); RandomAccessibleInterval<UnsignedByteType> colorStack = Views.stack( Converters.argbChannel( colored, 1 ), Converters.argbChannel( colored, 2 ), Converters.argbChannel( colored, 3 ) ); ImgPlus<UnsignedByteType> result = new ImgPlus<>(ImgView.wrap(colorStack, new PlanarImgFactory<>()), input.getName()); int lastAxis = colored.numDimensions(); for (int i = 0; i < lastAxis; i++) result.setAxis(input.axis(i).copy(), i); result.setAxis(new DefaultLinearAxis(Axes.CHANNEL), lastAxis); return ImgPlusViews.moveAxis(result, lastAxis, 2); }