use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class UnaryRealTypeMathTest method assertRandomUniform.
private void assertRandomUniform(final double i, final double o, final long seed) {
final DoubleType in = new DoubleType(i);
final DoubleType out = (DoubleType) ops.run(RandomUniform.class, in.createVariable(), in, seed);
assertEquals(o, out.get(), 0);
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class StatisticsTest method MeanStdTest.
@Test
public void MeanStdTest() {
float sum = 0.0f;
for (int i = 0; i < arraySize; i++) {
sum += array[i];
}
float variance = 0.0f;
float mean1 = sum / (arraySize);
// use the mean to calculate the variance
for (int i = 0; i < arraySize; i++) {
float temp = array[i] - mean1;
variance += temp * temp;
}
variance = variance / arraySize;
float std1 = (float) Math.sqrt(variance);
// calculate mean using ops
final DoubleType mean2 = new DoubleType();
ops.run(IterableMean.class, mean2, img);
// check that the ratio between mean1 and mean2 is 1.0
Assert.assertEquals(1.0, mean1 / mean2.getRealFloat(), delta);
// calculate standard deviation using ops
final DoubleType std2 = new DoubleType();
ops.run(IterableStandardDeviation.class, std2, img);
// check that the ratio between std1 and std2 is 1.0
Assert.assertEquals(1.0, std1 / std2.getRealFloat(), delta);
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class AddDimensionViewTest method addDimensionTest.
@Test
public void addDimensionTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
MixedTransformView<DoubleType> il2 = Views.addDimension((RandomAccessible<DoubleType>) img);
MixedTransformView<DoubleType> opr = ops.transform().addDimensionView((RandomAccessible<DoubleType>) img);
assertEquals(il2.numDimensions(), opr.numDimensions());
boolean[] il2Transform = new boolean[3];
boolean[] oprTransform = new boolean[3];
il2.getTransformToSource().getComponentZero(il2Transform);
opr.getTransformToSource().getComponentZero(oprTransform);
for (int i = 0; i < il2Transform.length; i++) {
assertEquals(il2Transform[i], oprTransform[i]);
}
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class AddDimensionViewTest method addDimensionMinMaxTest.
@Test
public void addDimensionMinMaxTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
int max = 20;
int min = 0;
IntervalView<DoubleType> il2 = Views.addDimension(img, min, max);
IntervalView<DoubleType> opr = ops.transform().addDimensionView(img, min, max);
assertEquals(il2.numDimensions(), opr.numDimensions(), 0.0);
for (int i = 0; i < il2.numDimensions(); i++) {
assertEquals(il2.dimension(i), opr.dimension(i), 0.0);
}
}
use of net.imglib2.type.numeric.real.DoubleType in project imagej-ops by imagej.
the class CollapseRealViewTest method defaultCollapseRealTest.
@Test
public void defaultCollapseRealTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 10, 10 }, new DoubleType());
CompositeIntervalView<DoubleType, RealComposite<DoubleType>> il2 = Views.collapseReal((RandomAccessibleInterval<DoubleType>) img);
CompositeIntervalView<DoubleType, RealComposite<DoubleType>> opr = ops.transform().collapseRealView((RandomAccessibleInterval<DoubleType>) img);
assertEquals(il2.numDimensions(), opr.numDimensions());
CompositeView<DoubleType, RealComposite<DoubleType>> il2_2 = Views.collapseReal((RandomAccessible<DoubleType>) img, 1);
CompositeView<DoubleType, RealComposite<DoubleType>> opr_2 = ops.transform().collapseRealView((RandomAccessible<DoubleType>) img, 1);
assertEquals(il2_2.numDimensions(), opr_2.numDimensions());
}
Aggregations