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

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

本文整理了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

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

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

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

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

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

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

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

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

  1. private void assertIncreasing( List< Img< IntType > > images )
  2. {
  3. for ( int i = 0; i < images.size(); i++ )
  4. {
  5. Img< IntType > image = images.get( i );
  6. assertEquals( i, image.firstElement().get() );
  7. }
  8. }

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

  1. protected < T extends BooleanType< T > > Img< T > calculate( final Img< T > source )
  2. {
  3. final Img< T > target = source.factory().create( source );
  4. final T extendedVal = source.firstElement().createVariable();
  5. extendedVal.set( getExtendedValue() );
  6. final ExtendedRandomAccessibleInterval< T, Img< T > > extended = Views.extendValue( source, extendedVal );
  7. calculate( extended, target );
  8. return target;
  9. }

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

  1. @BeforeClass
  2. public static void createImg() {
  3. Img<UnsignedByteType> tmp =
  4. ArrayImgs.unsignedBytes(new long[] { 100, 100 });
  5. Random rand = new Random(1234567890L);
  6. final Cursor<UnsignedByteType> cursor = tmp.cursor();
  7. while (cursor.hasNext()) {
  8. cursor.next().set(rand.nextInt((int) tmp.firstElement().getMaxValue()));
  9. }
  10. img = tmp;
  11. }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  1. @Test
  2. public void copyArrayImgWithOutputTest() {
  3. final Img<UnsignedByteType> output = input.factory().create(input,
  4. input.firstElement());
  5. ops.run(CopyArrayImg.class, output, input);
  6. final Cursor<UnsignedByteType> inc = input.cursor();
  7. final Cursor<UnsignedByteType> outc = output.cursor();
  8. while (inc.hasNext()) {
  9. assertTrue(outc.next().equals(inc.next()));
  10. }
  11. }
  12. }

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

  1. @Test
  2. public void copyRAIWithOutputTest() {
  3. final Img<UnsignedByteType> output = input.factory().create(input, input
  4. .firstElement());
  5. ops.run(CopyRAI.class, output, input);
  6. final Cursor<UnsignedByteType> inc = input.cursor();
  7. final Cursor<UnsignedByteType> outc = output.cursor();
  8. while (inc.hasNext()) {
  9. assertEquals(inc.next().get(), outc.next().get());
  10. }
  11. }

相关文章