• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java DoubleType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中net.imglib2.type.numeric.real.DoubleType的典型用法代码示例。如果您正苦于以下问题:Java DoubleType类的具体用法?Java DoubleType怎么用?Java DoubleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DoubleType类属于net.imglib2.type.numeric.real包,在下文中一共展示了DoubleType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
 
开发者ID:imagej,项目名称:imagej-tensorflow,代码行数:31,代码来源:TensorsTest.java


示例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);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:FractalDimensionWrapper.java


示例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());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:26,代码来源:CommonWrapperTests.java


示例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);
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:24,代码来源:CommonTest.java


示例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());
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:AxisUtilsTest.java


示例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);
	}
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:17,代码来源:StreamersTest.java


示例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));
}
 
开发者ID:bonej-org,项目名称:BoneJ2,代码行数:22,代码来源:StreamersTest.java


示例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);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:17,代码来源:DefaultMaxProbability.java


示例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);

}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:MeanTest.java


示例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);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:IntervalViewTest.java


示例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;
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:WrappedIntegralImg.java


示例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);
	}
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:22,代码来源:UnshearViewTest.java


示例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);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:20,代码来源:LocalMeanThresholdIntegral.java


示例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);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:27,代码来源:LocalPhansalkarThresholdIntegral.java


示例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);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:25,代码来源:InterpolateViewTest.java


示例16: compute

import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public void compute(final Mesh input, final DoubleType output) {

	final RealMatrix it = inertiaTensor.calculate(input);
	final EigenDecomposition ed = new EigenDecomposition(it);

	final double l1 = ed.getRealEigenvalue(0) - ed.getRealEigenvalue(2) + ed.getRealEigenvalue(1);
	final double l2 = ed.getRealEigenvalue(0) - ed.getRealEigenvalue(1) + ed.getRealEigenvalue(2);
	final double l3 = ed.getRealEigenvalue(2) - ed.getRealEigenvalue(0) + ed.getRealEigenvalue(1);

	final double g = 1 / (8 * Math.PI / 15);

	final double a = Math.pow(g * l1 * l1 / Math.sqrt(l2 * l3), 1 / 5d);
	final double b = Math.pow(g * l2 * l2 / Math.sqrt(l1 * l3), 1 / 5d);
	final double c = Math.pow(g * l3 * l3 / Math.sqrt(l1 * l2), 1 / 5d);

	double volumeEllipsoid = (4 / 3d * Math.PI * a * b * c);

	output.set(volume.calculate(input).get() / volumeEllipsoid);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:21,代码来源:DefaultSparenessMesh.java


示例17: testIntegralImageSimilarity

import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
/**
 * @see DefaultIntegralImg
 * @see SquareIntegralImg
 */
@SuppressWarnings({ "unchecked" })
@Test
public void testIntegralImageSimilarity() {
	RandomAccessibleInterval<LongType> out1 =
		(RandomAccessibleInterval<LongType>) ops.run(DefaultIntegralImg.class,
			in);
	RandomAccessibleInterval<DoubleType> out2 =
		(RandomAccessibleInterval<DoubleType>) ops.run(WrappedIntegralImg.class,
			in);

	// Remove 0s from integralImg by shifting its interval by +1
	final long[] min = new long[out2.numDimensions()];
	final long[] max = new long[out2.numDimensions()];

	for (int d = 0; d < out2.numDimensions(); ++d) {
		min[d] = out2.min(d) + 1;
		max[d] = out2.max(d);
	}

	// Define the Interval on the infinite random accessibles
	final FinalInterval interval = new FinalInterval(min, max);

	LocalThresholdTest.testIterableIntervalSimilarity(Views.iterable(out1),
		Views.iterable(Views.offsetInterval(out2, interval)));
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:30,代码来源:IntegralImgTest.java


示例18: testIntervalPermuteInverseDimensionCoordinates

import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testIntervalPermuteInverseDimensionCoordinates() {
	Img<DoubleType> img = ArrayImgs.doubles(2, 2);
	Cursor<DoubleType> c = img.cursor();
	Random r = new Random();
	while (c.hasNext()) {
		c.next().set(r.nextDouble());
	}
	IntervalView<DoubleType> expected = Views.permuteCoordinateInverse(img, new int[]{0, 1}, 1);
	Cursor<DoubleType> e = expected.cursor();
	RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesInverseView(img, new int[]{0, 1}, 1);
	RandomAccess<DoubleType> actualRA = actual.randomAccess();
	
	while (e.hasNext()) {
		e.next();
		actualRA.setPosition(e);
		assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
	}
	
	assertTrue(Intervals.equals(expected, actual));
	
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java


示例19: testIntervalPermuteCoordinates

import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Test
public void testIntervalPermuteCoordinates() {
	Img<DoubleType> img = ArrayImgs.doubles(2, 2);
	Cursor<DoubleType> c = img.cursor();
	Random r = new Random();
	while (c.hasNext()) {
		c.next().set(r.nextDouble());
	}
	IntervalView<DoubleType> expected = Views.permuteCoordinates(img, new int[]{0, 1});
	Cursor<DoubleType> e = expected.cursor();
	RandomAccessibleInterval<DoubleType> actual = ops.transform().permuteCoordinatesView(img, new int[]{0, 1});
	RandomAccess<DoubleType> actualRA = actual.randomAccess();
	
	while (e.hasNext()) {
		e.next();
		actualRA.setPosition(e);
		assertEquals(e.get().get(), actualRA.get().get(), 1e-10);
	}
	
	assertTrue(Intervals.equals(expected, actual));
	
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:23,代码来源:PermuteViewTest.java


示例20: compute

import net.imglib2.type.numeric.real.DoubleType; //导入依赖的package包/类
@Override
public void compute(Polygon input, DoubleType output) {
	double sum = 0;
	final int numVertices = input.getVertices().size();
	for (int i = 0; i < numVertices; i++) {

		final RealLocalizable p0 = input.getVertices().get(i);
		final RealLocalizable p1 = input.getVertices().get((i + 1) % numVertices);

		final double p0_x = p0.getDoublePosition(0);
		final double p0_y = p0.getDoublePosition(1);
		final double p1_x = p1.getDoublePosition(0);
		final double p1_y = p1.getDoublePosition(1);

		sum += p0_x * p1_y - p0_y * p1_x;
	}
	output.set(Math.abs(sum) / 2d);
}
 
开发者ID:imagej,项目名称:imagej-ops,代码行数:19,代码来源:DefaultSizePolygon.java



注:本文中的net.imglib2.type.numeric.real.DoubleType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultPlexusContainer类代码示例发布时间:2022-05-21
下一篇:
Java DefaultAnnotationHover类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap