Java Code Examples for net.imglib2.type.numeric.real.FloatType#setReal()
The following examples show how to use
net.imglib2.type.numeric.real.FloatType#setReal() .
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: StatisticsTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 6 votes |
@Test public void MinMaxTest() { float min1 = Float.MAX_VALUE; float max1 = Float.MIN_VALUE; // loop through the array calculating min and max for (int i = 0; i < arraySize; i++) { if (array[i] < min1) min1 = array[i]; if (array[i] > max1) max1 = array[i]; } // calculate min using ops FloatType min2 = new FloatType(); min2.setReal(Float.MAX_VALUE); ops.run(IterableMin.class, min2, img); // calculate max using ops FloatType max2 = new FloatType(); max2.setReal(Float.MIN_VALUE); ops.run(IterableMax.class, max2, img); // check to see if everything matches Assert.assertEquals(min1, min2.getRealFloat(), delta); Assert.assertEquals(max1, max2.getRealFloat(), delta); }
Example 2
Source File: MathBenchmarkTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
private ArrayImg<FloatType, ?> createConstantImg(long[] dims, float constant) { // create an input ArrayImg<FloatType, ?> img = new ArrayImgFactory<FloatType>().create(dims, new FloatType()); for (final FloatType value : img) { value.setReal(constant); } return img; }
Example 3
Source File: WatershedSeededTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void test() { long[] dims = { 15, 30 }; // create input image Img<FloatType> input = ArrayImgs.floats(dims); MersenneTwisterFast random = new MersenneTwisterFast(SEED); for (FloatType b : input) { b.setReal(random.nextDouble()); } // create 3 seeds Img<BitType> bits = ArrayImgs.bits(dims); RandomAccess<BitType> ra = bits.randomAccess(); ra.setPosition(new int[] { 0, 0 }); ra.get().set(true); ra.setPosition(new int[] { 4, 6 }); ra.get().set(true); ra.setPosition(new int[] { 10, 20 }); ra.get().set(true); // compute labeled seeds final ImgLabeling<Integer, IntType> labeledSeeds = ops.labeling().cca(bits, StructuringElement.EIGHT_CONNECTED); testWithoutMask(input, labeledSeeds); testWithMask(input, labeledSeeds); }
Example 4
Source File: FFTTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 5 votes |
/** * 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 5
Source File: DeconvolveTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 3 votes |
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 6
Source File: ConvolveTest.java From imagej-ops with BSD 2-Clause "Simplified" License | 3 votes |
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); } }