本文整理汇总了Java中net.imglib2.type.numeric.real.DoubleType.set方法的典型用法代码示例。如果您正苦于以下问题:Java DoubleType.set方法的具体用法?Java DoubleType.set怎么用?Java DoubleType.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.imglib2.type.numeric.real.DoubleType
的用法示例。
在下文中一共展示了DoubleType.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defaultIntervalTest
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Test
public void defaultIntervalTest() {
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, img).localizingCursor();
RandomAccess<DoubleType> opr = ops.transform().intervalView(img, img).randomAccess();
while (il2.hasNext()) {
DoubleType e = il2.next();
opr.setPosition(il2);
assertEquals(e.get(), opr.get().get(), 1e-10);
}
}
示例2: defaultRasterTest
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Test
public void defaultRasterTest() {
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());
}
RealRandomAccessible<DoubleType> realImg = Views.interpolate(img, new FloorInterpolatorFactory<DoubleType>());
RandomAccessibleOnRealRandomAccessible<DoubleType> il2 = Views.raster(realImg);
RandomAccessibleOnRealRandomAccessible<DoubleType> opr = ops.transform().rasterView(realImg);
Cursor<DoubleType> il2C = Views.interval(il2, img).localizingCursor();
RandomAccess<DoubleType> oprRA = Views.interval(opr, img).randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
}
示例3: 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 int nrGrayLevels = matrix.length;
final double meanx = coocMeanXFunc.calculate(matrix).get();
final double meany = coocMeanYFunc.calculate(matrix).get();
final double stdx = coocStdXFunc.calculate(matrix).get();
final double stdy = coocStdYFunc.calculate(matrix).get();
double sum = 0;
for (int i = 0; i < nrGrayLevels; i++) {
for (int j = 0; j < nrGrayLevels; j++) {
sum += i*j*matrix[i][j];
}
}
output.set((sum - (meanx*meany))/(stdx*stdy));
}
示例4: compute
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(RandomAccessibleInterval<B> interval, DoubleType output) {
final RandomAccess<B> access = interval.randomAccess();
long sumDeltaEuler = 0;
for (long z = 0; z < interval.dimension(2) - 1; z++) {
for (long y = 0; y < interval.dimension(1) - 1; y++) {
for (long x = 0; x < interval.dimension(0) - 1; x++) {
int index = neighborhoodEulerIndex(access, x, y, z);
sumDeltaEuler += EULER_LUT[index];
}
}
}
output.set(sumDeltaEuler / 8.0);
}
示例5: 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);
}
}
示例6: compute
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(Polygon input, DoubleType output) {
final List<? extends RealLocalizable> points = function.calculate(input).getVertices();
final double angleRad = -angle * Math.PI / 180.0;
double minX = Double.POSITIVE_INFINITY;
double maxX = Double.NEGATIVE_INFINITY;
for (RealLocalizable p : points) {
final double tmpX = p.getDoublePosition(0) * Math.cos(angleRad) - p.getDoublePosition(1) * Math.sin(angleRad);
minX = tmpX < minX ? tmpX : minX;
maxX = tmpX > maxX ? tmpX : maxX;
}
output.set(Math.abs(maxX - minX));
}
示例7: 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);
}
示例8: testIntervalSubsampleSteps
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Test
public void testIntervalSubsampleSteps() {
Img<DoubleType> img = ArrayImgs.doubles(10,10);
Random r = new Random();
for (DoubleType d : img) {
d.set(r.nextDouble());
}
SubsampleIntervalView<DoubleType> expected = Views.subsample((RandomAccessibleInterval<DoubleType>) img, 2, 1);
SubsampleIntervalView<DoubleType> actual = (SubsampleIntervalView<DoubleType>) ops.transform().subsampleView((RandomAccessibleInterval<DoubleType>)img, 2, 1);
Cursor<DoubleType> il2C = Views.interval(expected, new long[] { 0, 0 }, new long[] { 4, 9 }).localizingCursor();
RandomAccess<DoubleType> oprRA = actual.randomAccess();
while (il2C.hasNext()) {
il2C.next();
oprRA.setPosition(il2C);
assertEquals(il2C.get().get(), oprRA.get().get(), 1e-10);
}
assertTrue(Intervals.equals(expected, actual));
}
示例9: loadDouble
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
/**
* Load an HDF5 float64 dataset into a {@link CellImg} of {@link DoubleType}.
*
* @param reader
* @param dataset
* @param cellDimensions
*/
static public CellImg< DoubleType, ? > loadDouble(
final IHDF5Reader reader,
final String dataset,
final int[] cellDimensions )
{
final IHDF5DoubleReader float64Reader = reader.float64();
final long[] dimensions = reorder( reader.object().getDimensions( dataset ) );
final int n = dimensions.length;
final CellImg< DoubleType, ? > target = new CellImgFactory< DoubleType >( cellDimensions ).create( dimensions, new DoubleType() );
final long[] offset = new long[ n ];
final long[] targetCellDimensions = new long[ n ];
for ( int d = 0; d < n; )
{
cropCellDimensions( target, offset, cellDimensions, targetCellDimensions );
final RandomAccessibleInterval< DoubleType > targetBlock = Views.offsetInterval( target, offset, targetCellDimensions );
final MDDoubleArray targetCell = float64Reader.readMDArrayBlockWithOffset(
dataset,
Util.long2int( reorder( targetCellDimensions ) ),
reorder( offset ) );
int i = 0;
for ( final DoubleType t : Views.flatIterable( targetBlock ) )
t.set( targetCell.get( i++ ) );
for ( d = 0; d < n; ++d )
{
offset[ d ] += cellDimensions[ d ];
if ( offset[ d ] < dimensions[ d ] )
break;
else
offset[ d ] = 0;
}
}
return target;
}
示例10: process
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
private static final <T extends RealType<T>> Img<DoubleType> process(
final Img<T> img) {
final IntegralImgDouble<T> o =
new IntegralImgDouble<T>(img, new DoubleType(),
new Converter<T, DoubleType>() {
@Override
public final void convert(final T input, final DoubleType output) {
output.set(input.getRealDouble());
}
});
o.process();
return o.getResult();
}
示例11: 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[] pxminusxy = coocPXMinusYFunc.calculate(matrix);
double res = 0;
for (int k = 0; k <= matrix.length - 1; k++) {
res += k * k * pxminusxy[k];
}
output.set(res);
}
示例12: 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[] pxplusy = coocPXPlusFunc.calculate(matrix);
final int nrGrayLevels = matrix.length;
double res = 0;
for (int i = 2; i <= 2 * nrGrayLevels; i++) {
res += pxplusy[i] * Math.log(pxplusy[i] + EPSILON);
}
output.set(-res);
}
示例13: 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);
output.set(1 - (b / a));
}
示例14: compute
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(Polygon input, DoubleType output) {
output.set(feretAngle.calculate(minFeret.calculate(input)).get());
}
示例15: compute
import net.imglib2.type.numeric.real.DoubleType; //导入方法依赖的package包/类
@Override
public void compute(I input, DoubleType output) {
output.set(perimeterFunc.calculate(convexHullFunc.calculate(input)));
}