本文整理汇总了Java中net.imglib2.type.numeric.real.DoubleType类的典型用法代码示例。如果您正苦于以下问题:Java DoubleType类的具体用法?Java DoubleType怎么用?Java DoubleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DoubleType类属于net.imglib2.type.numeric.real包,在下文中一共展示了DoubleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testImgToTensorMapping
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
/** Tests the tensor(RAI, int[]) function */
@Test
public void testImgToTensorMapping() {
assertEquals(1, 1);
final long[] dims = new long[] { 5, 4, 3, 2 };
final int[] mapping = new int[] { 1, 3, 0, 2 }; // A strange mapping
final long[] shape = new long[] { 3, 5, 2, 4 };
final int n = dims.length;
// ByteType
testImg2TensorMappingForType(new ArrayImgFactory<ByteType>().create(dims, new ByteType()), mapping, n, shape,
DataType.UINT8);
// DoubleType
testImg2TensorMappingForType(new ArrayImgFactory<DoubleType>().create(dims, new DoubleType()), mapping, n,
shape, DataType.DOUBLE);
// FloatType
testImg2TensorMappingForType(new ArrayImgFactory<FloatType>().create(dims, new FloatType()), mapping, n, shape,
DataType.FLOAT);
// IntType
testImg2TensorMappingForType(new ArrayImgFactory<IntType>().create(dims, new IntType()), mapping, n, shape,
DataType.INT32);
// LongType
testImg2TensorMappingForType(new ArrayImgFactory<LongType>().create(dims, new LongType()), mapping, n, shape,
DataType.INT64);
}
示例2: addSubspaceTable
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
private void addSubspaceTable(final Subspace<BitType> subspace,
final List<ValuePair<DoubleType, DoubleType>> pairs)
{
final String label = inputImage.getName() + " " + subspace.toString();
final GenericColumn labelColumn = ResultUtils.createLabelColumn(label, pairs
.size());
final DoubleColumn xColumn = new DoubleColumn("-log(size)");
final DoubleColumn yColumn = new DoubleColumn("log(count)");
pairs.stream().map(p -> p.a.get()).forEach(xColumn::add);
pairs.stream().map(p -> p.b.get()).forEach(yColumn::add);
final GenericTable resultsTable = new DefaultGenericTable();
resultsTable.add(labelColumn);
resultsTable.add(xColumn);
resultsTable.add(yColumn);
subspaceTables.add(resultsTable);
}
示例3: test2DImageCancelsPlugin
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
public static <C extends Command> void test2DImageCancelsPlugin(
final ImageJ imageJ, final Class<C> commandClass) throws Exception
{
// SETUP
final UserInterface mockUI = mockUIService(imageJ);
// Create an image with only two spatial dimensions
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL);
final Img<DoubleType> img = ArrayImgs.doubles(10, 10, 3);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, cAxis);
// EXECUTE
final CommandModule module = imageJ.command().run(commandClass, true,
"inputImage", imgPlus).get();
// VERIFY
assertTrue("2D image should have cancelled the plugin", module
.isCanceled());
assertEquals("Cancel reason is incorrect", CommonMessages.NOT_3D_IMAGE,
module.getCancelReason());
verify(mockUI, timeout(1000)).dialogPrompt(anyString(), anyString(), any(),
any());
}
示例4: testToBitTypeImgPlus
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testToBitTypeImgPlus() throws AssertionError {
final String unit = "mm";
final String name = "Test image";
final double scale = 0.5;
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X, unit, scale);
final Img<DoubleType> img = ArrayImgs.doubles(3);
final ImgPlus<DoubleType> source = new ImgPlus<>(img, name, xAxis);
final ImgPlus<BitType> result = Common.toBitTypeImgPlus(IMAGE_J.op(),
source);
final int dimensions = source.numDimensions();
assertEquals("Number of dimensions copied incorrectly", dimensions, result
.numDimensions());
assertTrue("Dimensions copied incorrectly", IntStream.range(0, dimensions)
.allMatch(d -> source.dimension(d) == result.dimension(d)));
assertEquals("Image name was not copied", name, result.getName());
assertEquals("Axis type was not copied", Axes.X, result.axis(0).type());
assertEquals("Axis unit was not copied", unit, result.axis(0).unit());
assertEquals("Axis scale was not copied", scale, result.axis(0)
.averageScale(0, 1), 1e-12);
}
示例5: testGetXYZIndices
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testGetXYZIndices() throws Exception {
final int[] expectedIndices = { 0, 1, 3 };
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final DefaultLinearAxis cAxis = new DefaultLinearAxis(Axes.CHANNEL);
final DefaultLinearAxis zAxis = new DefaultLinearAxis(Axes.Z);
final Img<DoubleType> img = ArrayImgs.doubles(1, 1, 1, 1);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
yAxis, cAxis, zAxis);
final Optional<int[]> result = AxisUtils.getXYZIndices(imgPlus);
assertTrue("Optional should be present", result.isPresent());
assertArrayEquals("Indices are incorrect", expectedIndices, result.get());
}
示例6: testRealDoubleStream
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testRealDoubleStream() throws Exception {
final List<DoubleType> list = Arrays.asList(new DoubleType(2),
new DoubleType(3), new DoubleType(11));
final List<Double> result = Streamers.realDoubleStream(list).boxed()
.collect(Collectors.toList());
assertEquals("Stream had wrong number of elements", list.size(), result
.size());
for (int i = 0; i < list.size(); i++) {
assertEquals("Stream had wrong values", list.get(i).getRealDouble(),
result.get(i), 1e-12);
}
}
示例7: testSpatialAxisStream
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testSpatialAxisStream() throws Exception {
// Create a test image that has spatial axes
final DefaultLinearAxis xAxis = new DefaultLinearAxis(Axes.X);
final DefaultLinearAxis tAxis = new DefaultLinearAxis(Axes.TIME);
final DefaultLinearAxis yAxis = new DefaultLinearAxis(Axes.Y);
final long[] dimensions = { 10, 3, 10 };
final Img<DoubleType> img = ArrayImgs.doubles(dimensions);
final ImgPlus<DoubleType> imgPlus = new ImgPlus<>(img, "Test image", xAxis,
tAxis, yAxis);
final List<AxisType> result = Streamers.spatialAxisStream(imgPlus).map(
TypedAxis::type).collect(Collectors.toList());
assertNotNull("Stream should not be null", result);
assertEquals("Wrong number of axes in stream", 2, result.size());
assertEquals("Axes in the stream are in wrong order", Axes.X, result.get(
0));
assertEquals("Axes in the stream are in wrong order", Axes.Y, result.get(
1));
}
示例8: compute
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public void compute(final IterableInterval<T> input, final DoubleType output) {
final double[][] matrix = getCooccurrenceMatrix(input);
final double nrGreyLevel = matrix.length;
double res = 0;
for (int i = 0; i < nrGreyLevel; i++) {
for (int j = 0; j < nrGreyLevel; j++) {
if (matrix[i][j] > res)
res = matrix[i][j];
}
}
output.set(res);
}
示例9: testMean
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testMean() {
final Img<ByteType> image = generateByteArrayTestImg(true, 40, 50);
final DoubleType mean = new DoubleType();
ops.run(IterableMean.class, mean, image);
assertEquals(1.0 / 15.625, mean.get(), 0.0);
Cursor<ByteType> c = image.cursor();
// this time lets just make every value 100
while (c.hasNext()) {
c.fwd();
c.get().setReal(100.0);
}
ops.run(IterableMean.class, mean, image);
// the mean should be 100
assertEquals(100.0, mean.get(), 0.0);
}
示例10: intervalMinMaxTest
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void intervalMinMaxTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
Cursor<DoubleType> il2 = Views.interval(img, new long[]{1, 1}, new long[]{8,9}).localizingCursor();
RandomAccess<DoubleType> opr = ops.transform().intervalView(img, new long[]{1, 1}, new long[]{8,9}).randomAccess();
while (il2.hasNext()) {
DoubleType e = il2.next();
opr.setPosition(il2);
assertEquals(e.get(), opr.get().get(), 1e-10);
}
}
示例11: calculate
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public RandomAccessibleInterval<DoubleType> calculate(
final RandomAccessibleInterval<I> input)
{
// Create IntegralImg from input
integralImg = new IntegralImg<>(input, new DoubleType(),
new RealDoubleConverter<I>());
// integralImg will be larger by one pixel in each dimension than input
// due
// to the computation of the integral image
RandomAccessibleInterval<DoubleType> img = null;
if (integralImg.process()) {
img = integralImg.getResult();
}
return img;
}
示例12: defaultUnshearTest
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void defaultUnshearTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[] { 2, 2 }, new DoubleType());
Cursor<DoubleType> imgC = img.cursor();
while (imgC.hasNext()) {
imgC.next().set(1);
}
TransformView<DoubleType> il2 = Views.unshear(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
TransformView<DoubleType> opr = ops.transform().unshearView(Views.shear(Views.extendZero(img), 0, 1), 0, 1);
Cursor<DoubleType> il2C = Views.interval(il2, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 }))
.cursor();
RandomAccess<DoubleType> oprRA = Views
.interval(opr, new FinalInterval(new long[] { 0, 0 }, new long[] { 3, 3 })).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
示例13: compute
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType sum = new DoubleType();
integralMean.compute(neighborhood, sum);
// Subtract the contrast
sum.sub(new DoubleType(c));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = new DoubleType();
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(sum) > 0);
}
示例14: compute
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public void compute(final I center,
final RectangleNeighborhood<Composite<DoubleType>> neighborhood,
final BitType output)
{
final DoubleType mean = new DoubleType();
integralMean.compute(neighborhood, mean);
final DoubleType variance = new DoubleType();
integralVariance.compute(neighborhood, variance);
final DoubleType stdDev = new DoubleType(Math.sqrt(variance.get()));
final DoubleType threshold = new DoubleType(mean.getRealDouble() * (1.0d +
p * Math.exp(-q * mean.getRealDouble()) + k * ((stdDev.getRealDouble() /
r) - 1.0)));
// Set value
final Converter<I, DoubleType> conv = new RealDoubleConverter<>();
final DoubleType centerPixelAsDoubleType = variance; // NB: Reuse
// DoubleType
conv.convert(center, centerPixelAsDoubleType);
output.set(centerPixelAsDoubleType.compareTo(threshold) > 0);
}
示例15: defaultInterpolateTest
import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void defaultInterpolateTest() {
Img<DoubleType> img = new ArrayImgFactory<DoubleType>().create(new int[]{10, 10}, new DoubleType());
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
RealRandomAccess<DoubleType> il2 = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
RealRandomAccess<DoubleType> opr = ops.transform().interpolateView(img, new FloorInterpolatorFactory<DoubleType>()).realRandomAccess();
il2.setPosition(new double[]{1.75, 5.34});
opr.setPosition(new double[]{1.75, 5.34});
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[]{3, 7});
opr.setPosition(new double[]{3, 7});
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
il2.setPosition(new double[]{8.37, 3.97});
opr.setPosition(new double[]{8.37, 3.97});
assertEquals(il2.get().get(), opr.get().get(), 1e-10);
}