net.imglib2.img.Img.firstElement()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(127)

本文整理了Java中net.imglib2.img.Img.firstElement()方法的一些代码示例,展示了Img.firstElement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Img.firstElement()方法的具体详情如下:
包路径:net.imglib2.img.Img
类名称:Img
方法名:firstElement

Img.firstElement介绍

暂无

代码示例

代码示例来源:origin: net.imglib2/imglib2-script

/**
 * TODO
 * 
 * @param img The {@link Img} to transform.
 * @param matrix The values of the transformation matrix, ordered as explained above.
 * @param mode Either LINEAR or NEAREST_NEIGHBOR.
 */
public Affine3D(final Img<T> img, final float[] matrix, final Mode mode) throws Exception {
  this(img, matrix, mode, new OutOfBoundsConstantValueFactory<T,Img<T>>(img.firstElement().createVariable())); // default value is zero
}

代码示例来源:origin: net.imglib2/imglib2-script

@SuppressWarnings({ "rawtypes", "unchecked" })
private static final NumericType<?> withValue(final Img<? extends NumericType<?>> img, final NumericType<?> type, final Number val) {
  final NumericType t = img.firstElement().createVariable();
  if (ARGBType.class.isAssignableFrom(t.getClass())) {
    int i = val.intValue();
    t.set(new ARGBType(i));
  } else {
    ((RealType)t).setReal(val.doubleValue());
  }
  return t;
}

代码示例来源:origin: net.imglib2/imglib2-algorithms

/**
 * Computes a Gaussian convolution with any precision on an entire {@link Img} using the {@link OutOfBoundsMirrorFactory} with single boundary
 * 
 * @param sigma - the sigma for the convolution
 * @param input - the input {@link Img}
 */
public GaussNativeType( final double[] sigma, final Img<T> input, final OutOfBoundsFactory< T, Img<T> > outOfBounds )
{
  this( sigma, Views.extend( input, outOfBounds ), input, input.factory(), input.firstElement().createVariable() );
}

代码示例来源:origin: net.imglib2/imglib2-roi

@Override
  public Labeling< LL > create( final long[] dim )
  {
    return new NativeImgLabeling< LL, I >( img.factory().create( dim, img.firstElement().createVariable() ) );
  }
};

代码示例来源:origin: imglib/imglib2

private void assertIncreasing( List< Img< IntType > > images )
{
  for ( int i = 0; i < images.size(); i++ )
  {
    Img< IntType > image = images.get( i );
    assertEquals( i, image.firstElement().get() );
  }
}

代码示例来源:origin: net.imglib2/imglib2-algorithm

protected < T extends BooleanType< T > > Img< T > calculate( final Img< T > source )
{
  final Img< T > target = source.factory().create( source );
  final T extendedVal = source.firstElement().createVariable();
  extendedVal.set( getExtendedValue() );
  final ExtendedRandomAccessibleInterval< T, Img< T > > extended = Views.extendValue( source, extendedVal );
  calculate( extended, target );
  return target;
}

代码示例来源:origin: imagej/imagej-ops

@BeforeClass
public static void createImg() {
  Img<UnsignedByteType> tmp =
    ArrayImgs.unsignedBytes(new long[] { 100, 100 });
  Random rand = new Random(1234567890L);
  final Cursor<UnsignedByteType> cursor = tmp.cursor();
  while (cursor.hasNext()) {
    cursor.next().set(rand.nextInt((int) tmp.firstElement().getMaxValue()));
  }
  img = tmp;
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalMaxEntropyThreshold
 */
@Test
public void testLocalMaxEntropyThreshold() {
  ops.run(MaxEntropy.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalMedianThreshold
 */
@Test
public void testLocalMedianThreshold() {
  ops.run(LocalMedianThreshold.class, out, in, new RectangleShape(3, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE),
    0.0);
  assertEquals(true, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalMinErrorThreshold
 */
@Test
public void testLocalMinErrorThreshold() {
  ops.run(MinError.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(true, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalNiblackThreshold
 */
@Test
public void testLocalNiblackThreshold() {
  ops.run(LocalNiblackThreshold.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE),
    0.2, 0.0);
  assertEquals(true, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalRenyiEntropyThreshold
 */
@Test
public void testLocalRenyiEntropyThreshold() {
  ops.run(RenyiEntropy.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalShanbhagThreshold
 */
@Test
public void testLocalShanbhagThreshold() {
  ops.run(Shanbhag.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalYenThreshold
 */
@Test
public void testLocalYenThreshold() {
  ops.run(Yen.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

@Test
public void copyTypeTest() {
  Img<FloatType> inputFloat = new ArrayImgFactory<FloatType>().create(
      new int[] { 120, 100 }, new FloatType());
  @SuppressWarnings("unchecked")
  Img<FloatType> output = (Img<FloatType>) ops
      .run(CopyII.class, inputFloat);
  
  assertTrue("Should be FloatType.", output.firstElement() instanceof FloatType);
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalHuangThreshold
 */
@Test
public void testLocalHuangThreshold() {
  ops.run(Huang.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(true, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalPercentileThreshold
 */
@Test
public void testLocalPercentileThreshold() {
  ops.run(Percentile.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

/**
 * @see LocalRosinThreshold
 */
@Test
public void testLocalRosinThreshold() {
  ops.run(Rosin.class, out, in, new RectangleShape(1, false),
    new OutOfBoundsMirrorFactory<ByteType, Img<ByteType>>(Boundary.SINGLE));
  assertEquals(false, out.firstElement().get());
}

代码示例来源:origin: imagej/imagej-ops

@Test
  public void copyArrayImgWithOutputTest() {
    final Img<UnsignedByteType> output = input.factory().create(input,
        input.firstElement());

    ops.run(CopyArrayImg.class, output, input);

    final Cursor<UnsignedByteType> inc = input.cursor();
    final Cursor<UnsignedByteType> outc = output.cursor();

    while (inc.hasNext()) {
      assertTrue(outc.next().equals(inc.next()));
    }
  }
}

代码示例来源:origin: imagej/imagej-ops

@Test
public void copyRAIWithOutputTest() {
  final Img<UnsignedByteType> output = input.factory().create(input, input
    .firstElement());
  ops.run(CopyRAI.class, output, input);
  final Cursor<UnsignedByteType> inc = input.cursor();
  final Cursor<UnsignedByteType> outc = output.cursor();
  while (inc.hasNext()) {
    assertEquals(inc.next().get(), outc.next().get());
  }
}

相关文章