net.imglib2.Point Java Examples

The following examples show how to use net.imglib2.Point. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestImageAccessor.java    From Colocalisation_Analysis with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Gaussian Smooth of the input image using intermediate float format.
 * @param <T>
 * @param img
 * @param sigma
 * @return
 */
public static <T extends RealType<T> & NativeType<T>> RandomAccessibleInterval<T> gaussianSmooth(
		RandomAccessibleInterval<T> img, double[] sigma) {
	Interval interval = Views.iterable(img);

	ImgFactory<T> outputFactory = new ArrayImgFactory<T>(Util.getTypeFromInterval(img));
	final long[] dim = new long[ img.numDimensions() ];
	img.dimensions(dim);
	RandomAccessibleInterval<T> output = outputFactory.create( dim );

	final long[] pos = new long[ img.numDimensions() ];
	Arrays.fill(pos, 0);
	Localizable origin = new Point(pos);

	ImgFactory<FloatType> tempFactory = new ArrayImgFactory<FloatType>(new FloatType());
	RandomAccessible<T> input = Views.extendMirrorSingle(img);
	Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);

	return output;
}
 
Example #2
Source File: PhaseCorrelationPeak2.java    From BigStitcher with GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) {
	
	double o1 = 6;
	double o2 = Double.NEGATIVE_INFINITY;
	int np1 = 30;
	int np2 = 20;

	System.out.println( Double.isInfinite( o2 ));

	int ccCompare = Double.compare(o1, o2);
	if (ccCompare != 0)
		System.out.println( ccCompare );
	else 
		System.out.println( (int)(np1 - np2) );
	
	System.exit( 0 );
	PhaseCorrelationPeak2 peaks = new PhaseCorrelationPeak2(new Point(new int[] {10, 10}), 1.0);
	Dimensions pcmDims = new FinalDimensions(new int[] {50, 50});
	Dimensions imgDims = new FinalDimensions(new int[] {30, 30});
	PhaseCorrelation2Util.expandPeakToPossibleShifts(peaks, pcmDims, imgDims, imgDims);
	
}
 
Example #3
Source File: ColocalisationTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * Gaussian Smooth of the input image using intermediate float format.
 * 
 * @param <T>
 * @param img
 * @param sigma
 * @return
 */
public static <T extends RealType<T> & NativeType<T>>
	Img<T> gaussianSmooth(RandomAccessibleInterval<T> img,
		double[] sigma)
{
	Interval interval = Views.iterable(img);

	ImgFactory<T> outputFactory = new ArrayImgFactory<>(Util.getTypeFromInterval(img));
	final long[] dim = new long[img.numDimensions()];
	img.dimensions(dim);
	Img<T> output = outputFactory.create(dim);

	final long[] pos = new long[img.numDimensions()];
	Arrays.fill(pos, 0);
	Localizable origin = new Point(pos);

	ImgFactory<FloatType> tempFactory = new ArrayImgFactory<>(new FloatType());
	RandomAccessible<T> input = Views.extendMirrorSingle(img);
	Gauss.inFloat(sigma, input, interval, output, origin, tempFactory);

	return output;
}
 
Example #4
Source File: RigidWarp3D.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args)
{
	RigidWarp3D warp = new RigidWarp3D();
	AffineGet affine = warp
			.getAffine( new double[] { Math.cos( Math.PI / 4 ) - 1, 0, 0, Math.sin( Math.PI / 4 ), 2, 2, 2 } );
	System.out.println( Util.printCoordinates( affine.getRowPackedCopy() ) );

	for ( int d = 0; d < 3; d++ )
		for ( int p = 0; p < warp.numParameters(); p++ )
			System.out.println( warp.partial( new Point( 1, 2, 3 ), d, p ) );
}
 
Example #5
Source File: RigidWarp2D.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args)
{
	RigidWarp aw = new RigidWarp( 2 );
	System.out.println( Util.printCoordinates( aw.getAffine( new double[] {Math.PI / 2, 0, 0} ).getRowPackedCopy() ) );
	
	for (int d = 0; d<2; d++)
		for (int p = 0; p<3; p++)
			System.out.println( aw.partial( new Point( 2,3 ), d, p ) );
}
 
Example #6
Source File: FFTTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * utility that places a sphere in the center of the image
 * 
 * @param img
 */
private void placeSphereInCenter(final 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);

	final HyperSphere<FloatType> hyperSphere = new HyperSphere<>(img, center,
		2);

	for (final FloatType value : hyperSphere) {
		value.setReal(1);
	}
}
 
Example #7
Source File: PhaseCorrelation2Util.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public static void main( String[] args )
	{
		final Point p = new Point( 90, 90 ); // identical to (-10,-10), so subpixel localization can move on periodic condition outofbounds
		PhaseCorrelationPeak2 pcp = new PhaseCorrelationPeak2( p, 5 );

		Dimensions pcmDims = new FinalDimensions( 100, 100 );
		Dimensions p1 = new FinalDimensions( 80, 81 );
		Dimensions p2 = new FinalDimensions( 91, 90 );

		final List<PhaseCorrelationPeak2> peaks = expandPeakToPossibleShifts( pcp, pcmDims, p1, p2 );

		for ( final PhaseCorrelationPeak2 pc : peaks )
			System.out.println( Util.printCoordinates( pc.getShift() ) );

		Img< FloatType > a = ImgLib2Util.openAs32Bit( new File( "73.tif.zip" ) );
		Img< FloatType > b = ImgLib2Util.openAs32Bit( new File( "74.tif.zip" ) );

//		BenchmarkHelper.benchmarkAndPrint( 10, true, new Runnable()
//		{
//			@Override
//			public void run()
//			{
//				System.out.println( getCorrelation ( a, b ) );
//			}
//		} );

		BenchmarkHelper.benchmarkAndPrint( 10, true, new Runnable()
		{
			@Override
			public void run()
			{
				PairwiseStitching.getShift( a, b, new Translation3D(), new Translation3D(),
						new PairwiseStitchingParameters(), Executors.newFixedThreadPool( Runtime.getRuntime().availableProcessors() ) );
			}
		} );

//		System.out.println( getCorrelation ( a, b ) );
//		System.out.println( getCorrelation ( a, c ) );
//		System.out.println( getCorrelation ( b, c ) );
	}
 
Example #8
Source File: PhaseCorrelationPeak2.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public PhaseCorrelationPeak2(Localizable pcmPosition, double phaseCorr)
{
	this.pcmLocation = new Point( pcmPosition );
	this.shift = null;
	this.subpixelPcmLocation = null;
	this.subpixelShift = null;
	this.phaseCorr = phaseCorr;
	this.crossCorr = 0.0;
	this.nPixel = 0;
}
 
Example #9
Source File: PhaseCorrelationPeak2.java    From BigStitcher with GNU General Public License v2.0 5 votes vote down vote up
public PhaseCorrelationPeak2(PhaseCorrelationPeak2 src){
	this.pcmLocation = new Point(src.pcmLocation);
	this.shift = src.shift == null? null : new Point(src.shift);
	this.subpixelPcmLocation = src.subpixelPcmLocation == null ? null : new RealPoint( src.subpixelPcmLocation );
	this.subpixelShift = src.subpixelShift == null ? null : new RealPoint( src.subpixelShift );
	this.phaseCorr = src.phaseCorr;
	this.crossCorr = src.crossCorr;
	this.nPixel = src.nPixel;
}
 
Example #10
Source File: FloodFill.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings({"rawtypes", "unchecked"})
private void fillAt(final double x, final double y, final long fill)
{
	final ViewerState viewerState   = viewer.getState();

	// TODO should this check happen outside?
	if (!isVisible.getAsBoolean())
	{
		LOG.info("Selected source is not visible -- will not fill");
		return;
	}

	final int               level          = 0;
	final AffineTransform3D labelTransform = new AffineTransform3D();
	// TODO What to do for time series?
	final int               time           = 0;
	source.getSourceTransform(time, level, labelTransform);

	final RealPoint rp = setCoordinates(x, y, viewer, labelTransform);
	final Point     p  = new Point(rp.numDimensions());
	for (int d = 0; d < p.numDimensions(); ++d)
	{
		p.setPosition(Math.round(rp.getDoublePosition(d)), d);
	}

	LOG.debug("Filling source {} with label {} at {}", source, fill, p);
	try
	{
		fill(time, level, fill, p, assignment);
	} catch (final MaskInUse e)
	{
		LOG.info(e.getMessage());
	}

}
 
Example #11
Source File: ShuffledView.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T> RandomAccessibleInterval<T> cropAtCenter(
	final RandomAccessibleInterval<T> image, final int[] blockSize)
{
	final long[] pos = new long[image.numDimensions()];
	for (int d = 0; d < pos.length; d++) {
		pos[d] = (image.dimension(d) % blockSize[d]) / 2;
	}
	return cropAt(image, blockSize, new Point(pos));
}
 
Example #12
Source File: ShuffledView.java    From imagej-ops with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public static <T> RandomAccessibleInterval<T> cropAtMax(
	final RandomAccessibleInterval<T> image, final int[] blockSize)
{
	final long[] pos = new long[image.numDimensions()];
	for (int d = 0; d < pos.length; d++) {
		pos[d] = image.dimension(d) % blockSize[d];
	}
	return cropAt(image, blockSize, new Point(pos));
}
 
Example #13
Source File: NonCirculantNormalizationFactor.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
protected void createNormalizationImageSemiNonCirculant(Interval fastFFTInterval) {

		// k is the window size (valid image region)
		final int length = k.numDimensions();

		final long[] n = new long[length];
		final long[] nFFT = new long[length];

		// n is the valid image size plus the extended region
		// also referred to as object space size
		for (int d = 0; d < length; d++) {
			n[d] = k.dimension(d) + l.dimension(d) - 1;
		}

		// nFFT is the size of n after (potentially) extending further
		// to a fast FFT size
		for (int d = 0; d < length; d++) {
			nFFT[d] = fastFFTInterval.dimension(d);
		}

		FinalDimensions fd = new FinalDimensions(nFFT);

		// create the normalization image
		normalization = create.calculate(fd);

		// size of the measurement window
		final Point size = new Point(length);
		final long[] sizel = new long[length];

		for (int d = 0; d < length; d++) {
			size.setPosition(k.dimension(d), d);
			sizel[d] = k.dimension(d);
		}

		// starting point of the measurement window when it is centered in fft space
		final Point start = new Point(length);
		final long[] startl = new long[length];
		final long[] endl = new long[length];

		for (int d = 0; d < length; d++) {
			start.setPosition((nFFT[d] - k.dimension(d)) / 2, d);
			startl[d] = (nFFT[d] - k.dimension(d)) / 2;
			endl[d] = startl[d] + sizel[d] - 1;
		}

		// size of the object space
		final Point maskSize = new Point(length);
		final long[] maskSizel = new long[length];

		for (int d = 0; d < length; d++) {
			maskSize.setPosition(Math.min(n[d], nFFT[d]), d);
			maskSizel[d] = Math.min(n[d], nFFT[d]);
		}

		// starting point of the object space within the fft space
		final Point maskStart = new Point(length);
		final long[] maskStartl = new long[length];

		for (int d = 0; d < length; d++) {
			maskStart.setPosition((Math.max(0, nFFT[d] - n[d]) / 2), d);
			maskStartl[d] = (Math.max(0, nFFT[d] - n[d]) / 2);
		}

		final RandomAccessibleInterval<O> temp = Views.interval(normalization,
			new FinalInterval(startl, endl));
		final Cursor<O> normCursor = Views.iterable(temp).cursor();

		// draw a cube the size of the measurement space
		while (normCursor.hasNext()) {
			normCursor.fwd();
			normCursor.get().setReal(1.0);
		}

		final Img<O> tempImg = create.calculate(fd);

		// 3. correlate psf with the output of step 2.
		correlater.compute(normalization, tempImg);

		normalization = tempImg;

		final Cursor<O> cursorN = normalization.cursor();

		while (cursorN.hasNext()) {
			cursorN.fwd();

			if (cursorN.get().getRealFloat() <= 1e-3f) {
				cursorN.get().setReal(1.0f);

			}
		}
	}
 
Example #14
Source File: ConvolveTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/** tests fft based convolve */
@Test
public void testCreateAndConvolvePoints() {

	final int xSize = 128;
	final int ySize = 128;
	final int zSize = 128;

	int[] size = new int[] { xSize, ySize, zSize };

	Img<DoubleType> phantom = ops.create().img(size);

	RandomAccess<DoubleType> randomAccess = phantom.randomAccess();

	randomAccess.setPosition(new long[] { xSize / 2, ySize / 2, zSize / 2 });
	randomAccess.get().setReal(255.0);

	randomAccess.setPosition(new long[] { xSize / 4, ySize / 4, zSize / 4 });
	randomAccess.get().setReal(255.0);

	Point location = new Point(phantom.numDimensions());
	location.setPosition(new long[] { 3 * xSize / 4, 3 * ySize / 4, 3 * zSize /
		4 });

	HyperSphere<DoubleType> hyperSphere = new HyperSphere<>(phantom, location,
		5);

	for (DoubleType value : hyperSphere) {
		value.setReal(16);
	}

	// create psf using the gaussian kernel op (alternatively PSF could be an
	// input to the script)
	RandomAccessibleInterval<DoubleType> psf = ops.create().kernelGauss(
		new double[] { 5, 5, 5 }, new DoubleType());

	RandomAccessibleInterval<DoubleType> convolved = ops.create().img(size);

	// convolve psf with phantom
	convolved = ops.filter().convolve(convolved, phantom, psf);

	DoubleType sum = new DoubleType();
	DoubleType max = new DoubleType();
	DoubleType min = new DoubleType();

	ops.stats().sum(sum, Views.iterable(convolved));
	ops.stats().max(max, Views.iterable(convolved));
	ops.stats().min(min, Views.iterable(convolved));

	assertEquals(sum.getRealDouble(), 8750.000184601617, 0.0);
	assertEquals(max.getRealDouble(), 3.154534101486206, 0.0);
	assertEquals(min.getRealDouble(), -2.9776862220387557E-7, 0.0);
}
 
Example #15
Source File: ShuffledView.java    From imagej-ops with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static <T> RandomAccessibleInterval<T> cropAtMin(
	final RandomAccessibleInterval<T> image, final int[] blockSize)
{
	return cropAt(image, blockSize, new Point(image.numDimensions()));
}
 
Example #16
Source File: FourNeighborhoodExtremaTest.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testRandomPeaksMT()
{
	Img< FloatType > img = ArrayImgs.floats( 50, 50 );
	Random rnd = new Random( seed );
	
	for( FloatType t : img )
		t.set( rnd.nextFloat() );
	
	ArrayList< Pair< Localizable, Double > > correct = new ArrayList< Pair<Localizable,Double> >(); 
	
	RandomAccess<FloatType> ra = img.randomAccess();
	
	for ( int i = 0; i < 10; ++i ){
		for (int d = 0; d< img.numDimensions(); d++){
			ra.setPosition((int) (rnd.nextDouble() * 50), d);
		}
		ra.get().set((float) (rnd.nextDouble() + 1.0));
		
		correct.add(new ValuePair<Localizable, Double>(new Point(ra), new Double(ra.get().get())));
	}
	
	// sort the peaks in descending order
	Collections.sort(correct, new Comparator<Pair< Localizable, Double >>() {
		@Override
		public int compare(Pair<Localizable, Double> o1, Pair<Localizable, Double> o2) {
			return Double.compare(o2.getB(), o1.getB());
		}
	});
	
	int nMax = 5;
	ArrayList< Pair< Localizable, Double > > found = FourNeighborhoodExtrema.findMaxMT(Views.extendPeriodic(img), img, nMax, Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors()));
	assertEquals(nMax, found.size());
	
	
	long[] posCorrect = new long[img.numDimensions()];
	long[] posFound = new long[img.numDimensions()];
	
	for (int i = 0; i<found.size(); i++){			
		assertEquals(correct.get(i).getB(), found.get(i).getB());
		
		correct.get(i).getA().localize(posCorrect);
		found.get(i).getA().localize(posFound);			
		assertArrayEquals(posCorrect, posFound);
	}
}
 
Example #17
Source File: PhaseCorrelation2Util.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
public static List<PhaseCorrelationPeak2> expandPeakToPossibleShifts(
		PhaseCorrelationPeak2 peak, Dimensions pcmDims, Dimensions img1Dims, Dimensions img2Dims)
{
	int n = pcmDims.numDimensions();
	double[] subpixelDiff = new double[n];
	
	if (peak.getSubpixelPcmLocation() != null)
		for (int i = 0; i < n; i++)
			subpixelDiff[i] = peak.getSubpixelPcmLocation().getDoublePosition( i ) - peak.getPcmLocation().getIntPosition( i );

	int[] originalPCMPeakWithOffset = new int[n];
	peak.getPcmLocation().localize(originalPCMPeakWithOffset);

	int[] extensionImg1 = getSizeDifference(img1Dims, pcmDims);
	int[] extensionImg2 = getSizeDifference(img2Dims, pcmDims);
	int[] offset = new int[pcmDims.numDimensions()];
	for(int i = 0; i < offset.length; i++){
		offset[i] = (extensionImg2[i] - extensionImg1[i] ) / 2;
		originalPCMPeakWithOffset[i] += offset[i];
		originalPCMPeakWithOffset[i] %= pcmDims.dimension(i); 
	}		
	
	List<PhaseCorrelationPeak2> shiftedPeaks = new ArrayList<PhaseCorrelationPeak2>();
	for (int i = 0; i < Math.pow(2, pcmDims.numDimensions()); i++){
		int[] possibleShift = originalPCMPeakWithOffset.clone();
		PhaseCorrelationPeak2 peakWithShift = new PhaseCorrelationPeak2(peak);
		for (int d = 0; d < pcmDims.numDimensions(); d++){
			/*
			 * mirror the shift around the origin in dimension d if (i / 2^d) is even
			 * --> all possible shifts
			 */
			if ((i / (int) Math.pow(2, d) % 2) == 0){
				possibleShift[d] = possibleShift[d] < 0 ? possibleShift[d] + (int) pcmDims.dimension(d) : possibleShift[d] - (int) pcmDims.dimension(d);
			}
		}
		peakWithShift.setShift(new Point(possibleShift));

		if (peakWithShift.getSubpixelPcmLocation() != null)
		{
			double[] subpixelShift = new double[n];
			for (int j =0; j<n;j++){
				subpixelShift[j] = possibleShift[j] + subpixelDiff[j];
			}

			peakWithShift.setSubpixelShift( new RealPoint( subpixelShift ) );
		}
		shiftedPeaks.add(peakWithShift);
	}		
	return shiftedPeaks;
}
 
Example #18
Source File: FourNeighborhoodExtrema.java    From BigStitcher with GNU General Public License v2.0 4 votes vote down vote up
public static < T extends RealType< T > > ArrayList< Pair< Localizable, Double > > findMax( final RandomAccessible< T > img, final Interval region, final int maxN )
	{
		final Cursor< T > c = Views.iterable( Views.interval( img, region ) ).localizingCursor();
		final RandomAccess< T > r = img.randomAccess();
		final int n = img.numDimensions();

		final ArrayList< Pair< Localizable, Double > > list = new ArrayList< Pair< Localizable, Double > >();

		for ( int i = 0; i < maxN; ++i )
			list.add( new ValuePair< Localizable, Double >( null, -Double.MAX_VALUE ) );

A:		while ( c.hasNext() )
		{
			final double type = c.next().getRealDouble();
			r.setPosition( c );

			for ( int d = 0; d < n; ++d )
			{
				r.fwd( d );
				if ( type < r.get().getRealDouble() )
					continue A;
	
				r.bck( d );
				r.bck( d );
				
				if ( type < r.get().getRealDouble() )
					continue A;

				r.fwd( d );
			}

			
			for ( int i = maxN - 1; i >= 0; --i )
			{
				if ( type < list.get( i ).getB() )
				{
					if ( i == maxN - 1 )
					{
						continue A;
					}
					else
					{
						list.add( i + 1, new ValuePair< Localizable, Double >( new Point( c ), type ) );
						list.remove( maxN );
						continue A;
					}
				}
			}

			list.add( 0, new ValuePair< Localizable, Double >( new Point( c ), type ) );
			list.remove( maxN );
		}

		// remove all null elements
		for ( int i = maxN -1; i >= 0; --i )
			if ( list.get( i ).getA() == null )
				list.remove(  i );

		return list;
	}
 
Example #19
Source File: RestrictPainting.java    From paintera with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings({"unchecked", "rawtypes"})
public void restrictTo(final double x, final double y)
{
	final Source<?>   currentSource = sourceInfo.currentSourceProperty().get();
	final ViewerState viewerState   = viewer.getState();
	if (currentSource == null)
	{
		LOG.info("No current source selected -- will not fill");
		return;
	}

	final SourceState<?, ?> currentSourceState = sourceInfo.getState(currentSource);

	if (!currentSourceState.isVisibleProperty().get())
	{
		LOG.info("Selected source is not visible -- will not fill");
		return;
	}

	if (!(currentSource instanceof MaskedSource<?, ?>))
	{
		LOG.info("Selected source is not painting-enabled -- will not fill");
		return;
	}

	if (maskForLabel == null)
	{
		LOG.info("Cannot generate boolean mask for this source -- will not fill");
		return;
	}

	final MaskedSource<?, ?> source = (MaskedSource<?, ?>) currentSource;

	final Type<?> t = source.getDataType();

	if (!(t instanceof LabelMultisetType) && !(t instanceof IntegerType<?>))
	{
		LOG.info("Data type is not integer type or LabelMultisetType -- will not fill");
		return;
	}

	final AffineTransform3D screenScaleTransform = new AffineTransform3D();
	viewer.getRenderUnit().getScreenScaleTransform(0, screenScaleTransform);
	final int level, time;
	synchronized (viewerState)
	{
		level = viewerState.getBestMipMapLevel(screenScaleTransform, sourceInfo.currentSourceIndexInVisibleSources().get());
		time = viewerState.getTimepoint();
	}
	final AffineTransform3D labelTransform = new AffineTransform3D();
	source.getSourceTransform(time, level, labelTransform);

	final RealPoint rp = setCoordinates(x, y, viewer, labelTransform);
	final Point     p  = new Point(rp.numDimensions());
	for (int d = 0; d < p.numDimensions(); ++d)
	{
		p.setPosition(Math.round(rp.getDoublePosition(d)), d);
	}

	try
	{
		if (source.getDataType() instanceof LabelMultisetType)
		{
			restrictToLabelMultisetType((MaskedSource) source, time, level, p, requestRepaint);
		}
		else
		{
			restrictTo((MaskedSource) source, time, level, p, requestRepaint);
		}
	} catch (final MaskInUse e)
	{
		LOG.info("Mask already in use -- will not paint: {}", e.getMessage());
	}

}
 
Example #20
Source File: RidgeDetectionUtils.java    From imagej-ops with BSD 2-Clause "Simplified" License 3 votes vote down vote up
/**
 * Helper method to take a point in a n-d image and reduce it down to a 2
 * dimensional point (e.g. in 3D cartesian space removing the z-coordinate
 * from the point).
 * 
 * @param RA - the random access of the {@code n>2} dimensional image.
 * @return Point in 2D space.
 */
protected static Point get2DPoint(RandomAccess<DoubleType> RA) {
	long[] coords = new long[2];
	coords[0] = RA.getLongPosition(0);
	coords[1] = RA.getLongPosition(1);

	return new Point(coords);
}
 
Example #21
Source File: DeconvolveTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 3 votes vote down vote up
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, 30);

		for (final FloatType value : hyperSphere) {
			value.setReal(1);
		}
	}
 
Example #22
Source File: ConvolveTest.java    From imagej-ops with BSD 2-Clause "Simplified" License 3 votes vote down vote up
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);
		}
	}