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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations