Search in sources :

Example 1 with HyperSphere

use of net.imglib2.algorithm.region.hypersphere.HyperSphere in project imagej-ops by imagej.

the class ConvolveTest method placeSphereInCenter.

// utility to place a small sphere at the center of the image
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);
    }
}
Also used : HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point) FloatType(net.imglib2.type.numeric.real.FloatType) ComplexFloatType(net.imglib2.type.numeric.complex.ComplexFloatType)

Example 2 with HyperSphere

use of net.imglib2.algorithm.region.hypersphere.HyperSphere in project imagej-ops by imagej.

the class FFTTest method placeSphereInCenter.

/**
 * 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);
    }
}
Also used : HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point) FloatType(net.imglib2.type.numeric.real.FloatType) ComplexFloatType(net.imglib2.type.numeric.complex.ComplexFloatType)

Example 3 with HyperSphere

use of net.imglib2.algorithm.region.hypersphere.HyperSphere in project imagej-ops by imagej.

the class ConvolveTest method testCreateAndConvolvePoints.

/**
 * 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());
    // convolve psf with phantom
    RandomAccessibleInterval<DoubleType> convolved = ops.filter().convolve(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.00, 0.001);
    assertEquals(max.getRealDouble(), 3.155, 0.001);
    assertEquals(min.getRealDouble(), 2.978E-7, 0.001);
}
Also used : DoubleType(net.imglib2.type.numeric.real.DoubleType) HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point) AbstractOpTest(net.imagej.ops.AbstractOpTest) Test(org.junit.Test)

Example 4 with HyperSphere

use of net.imglib2.algorithm.region.hypersphere.HyperSphere in project imagej-ops by imagej.

the class DeconvolveTest method placeSphereInCenter.

// utility to place a small sphere at the center of the image
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);
    }
}
Also used : HyperSphere(net.imglib2.algorithm.region.hypersphere.HyperSphere) Point(net.imglib2.Point) Point(net.imglib2.Point) FloatType(net.imglib2.type.numeric.real.FloatType)

Aggregations

Point (net.imglib2.Point)4 HyperSphere (net.imglib2.algorithm.region.hypersphere.HyperSphere)4 FloatType (net.imglib2.type.numeric.real.FloatType)3 ComplexFloatType (net.imglib2.type.numeric.complex.ComplexFloatType)2 AbstractOpTest (net.imagej.ops.AbstractOpTest)1 DoubleType (net.imglib2.type.numeric.real.DoubleType)1 Test (org.junit.Test)1