net.imglib2.type.logic.BitType类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.3k)|赞(0)|评价(0)|浏览(80)

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

BitType介绍

[英]TODO
[中]待办事项

代码示例

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

@Override
public void mul( final double c )
{
  if ( c >= 0.5f )
    set( get() && true );
  else
    set( false );
}

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

@Override
public BitType copy()
{
  return new BitType( get() );
}

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

private int countForeground(final IterableInterval<BitType> interval) {
  int count = 0;
  for (final BitType element : interval) {
    count = count + element.getInteger();
  }
  return count;
}

代码示例来源:origin: net.imagej/imagej-deprecated

@Override
public BitType compute(BitType input1, BitType input2, BitType output) {
  output.set(input1);
  output.xor(input2);
  return output;
}

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

private void copy(final RandomAccessibleInterval<BitType> source,
  final RandomAccessibleInterval<BitType> target)
{
  final IterableInterval<BitType> targetIt = Views.iterable(target);
  final IterableInterval<BitType> sourceIt = Views.iterable(source);
  if (sourceIt.iterationOrder().equals(targetIt.iterationOrder())) {
    final Cursor<BitType> targetCursor = targetIt.cursor();
    final Cursor<BitType> sourceCursor = sourceIt.cursor();
    while (sourceCursor.hasNext()) {
      targetCursor.fwd();
      sourceCursor.fwd();
      targetCursor.get().set(sourceCursor.get().get());
    }
  }
  else { // Fallback to random access
    final RandomAccess<BitType> targetRA = target.randomAccess();
    final Cursor<BitType> sourceCursor = sourceIt.localizingCursor();
    while (sourceCursor.hasNext()) {
      sourceCursor.fwd();
      targetRA.setPosition(sourceCursor);
      targetRA.get().set(sourceCursor.get().get());
    }
  }
}

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

@Override
public boolean contains( final double[] position )
{
  /*
   * Quantize by nearest-neighbor (-0.5 < x < 0.5)
   */
  validate();
  for ( int i = 0; i < numDimensions(); i++ )
  {
    final long lPosition = ( long ) ( position[ i ] - origin[ i ] );
    if ( ( lPosition < minima[ i ] ) || ( lPosition > maxima[ i ] ) )
      return false;
    randomAccess.get().setPosition( lPosition, i );
  }
  return randomAccess.get().get().get();
}

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

private void drawLine( final RandomAccess< BitType > ra, final Polygon poly, final int idx1, final int idx2, final int dimX, final int dimY )
{
  p1[ 0 ] = poly.xpoints[ idx1 ];
  p1[ 1 ] = poly.ypoints[ idx1 ];
  p2[ 0 ] = poly.xpoints[ idx2 ];
  p2[ 1 ] = poly.ypoints[ idx2 ];
  final int[][] points = rasterizeLine( p1, p2 );
  for ( final int[] p : points )
  {
    ra.setPosition( p[ 0 ], dimX );
    ra.setPosition( p[ 1 ], dimY );
    ra.get().set( true );
  }
}

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

public static Img<BitType> drawCube(final long width, final long height, final long depth, final long padding) {
    final long totalPadding = 2 * padding;
    final Img<BitType> cube = ArrayImgs.bits(width + totalPadding, height + totalPadding, depth + totalPadding);
    final long x1 = padding + width;
    final long y1 = padding + height;
    final long z1 = padding + depth;
    final RandomAccess<BitType> access = cube.randomAccess();

    for (long z = padding; z < z1; z++) {
      access.setPosition(z, 2);
      for (long y = padding; y < y1; y++) {
        access.setPosition(y, 1);
        for (long x = padding; x < x1; x++) {
          access.setPosition(x, 0);
          access.get().setOne();
        }
      }
    }

    return cube;
  }
}

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

/**
 * Test with a cube that has a cavity inside
 * <p>
 * Here χ = β_0 - β_1 + β_2 = 1 - 0 + 1 = 2
 * </p>
 */
@Test
public void testHollowCube() throws Exception {
  final Img<BitType> img = drawCube(3, 3, 3, 1);
  final RandomAccess<BitType> access = img.randomAccess();
  // Add a cavity
  access.setPosition(new long[]{2, 2, 2});
  access.get().setZero();
  final double result = ops.topology().eulerCharacteristic26N(img).get();
  assertEquals("Euler characteristic (χ) is incorrect", 2.0, result, 1e-12);
}

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

result = img.factory().imgFactory(new BitType()).create( dim, new BitType() );
} catch (IncompatibleTypeException e) {
  throw new RuntimeException(e);
  cursorInput.setPosition( cursor );
  cursorOutput.setPosition( cursor );
  final float in = cursorInput.get().getRealFloat(); 
  if ( in < ditheringThreshold )
    cursorOutput.get().setZero();
    error = in - minValue; 
    cursorOutput.get().setOne();
    error = in - maxValue;

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

RandomAccess<BitType> raMask = mask.randomAccess();
for (BitType b : mask) {
  b.setZero();
    raMask.setPosition(new int[] { x, y });
    raMask.get().setOne();

代码示例来源:origin: net.imagej/imagej-deprecated

for ( x0 = -2; x0 < 0; x0++ )
  op.setPosition( x0, 0 );
  roiCur.reset();
  while ( roiCur.hasNext() )
    for ( i = 1; i < dim.length; i++ )
      op.setPosition( lineCur.getLongPosition( i ) + roiCur.getLongPosition( i ) - 1, i );
    kernel[ kernelIndex ] = op.get().getInteger();
    sum += kernel[ kernelIndex ];
    kernelIndex = ( kernelIndex + 1 ) % kernel.length;
    kernel[ kernelIndex ] = op.get().getInteger();
    sum += kernel[ kernelIndex ];
    kernelIndex = ( kernelIndex + 1 ) % kernel.length;
    r.get().set( ( kernelSize - sum ) < count );
    r.get().set( sum >= count );

代码示例来源:origin: net.imagej/imagej-deprecated

private boolean isMarkedAsVisited( final L label )
{
  if ( m_allowOverlap )
  {
    return m_visitedLabRA.get().getLabeling().contains( label );
  }
  return m_visitedRA.get().get();
}

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

private void markAsVisited( L label )
{
  if ( m_allowOverlap )
  {
    List< L > l = new ArrayList< L >( m_visitedLabRA.get().getLabeling() );
    l.add( label );
    m_visitedLabRA.get().setLabeling( l );
  }
  else
  {
    m_visitedRA.get().set( true );
  }
}

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

@Override
public String toString()
{
  final boolean value = get();
  return value ? "1" : "0";
}

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

@Override
  public BitType createOutput() {
    return new BitType();
  }
}

代码示例来源:origin: net.imagej/imagej-common

@Override
public void setLong(BitType val, long v) {
  if (v == 0) val.set(false);
  else val.set(true);
}

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

/**
 * Tests {@link BitType#setBigInteger(BigInteger)} and ensures that the value
 * returned is within BitType range.
 */
@Test
public void testSetBigInteger() {
  final BitType ul = new BitType( false );
  assertEquals( ul.get(), false );
  final BigInteger bi = new BigInteger( "AAAAAA3141343BBBBBBBBBBB4134", 16 );
  ul.setBigInteger( bi );
  assertEquals( ul.get(), true );
}

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

/**
 * Test method for {@link net.imglib2.type.logic.BitType#setOne()}.
 */
@Test
public void testSetOne()
{
  for ( final BitType t : img )
    t.setOne();
  for ( final BitType t : img )
    assertTrue( t.get() );
}

代码示例来源:origin: net.imagej/imagej-common

private RandomAccessible<BitType> constantImg(final int numDims) {
  final long[] dims = new long[numDims];
  Arrays.fill(dims, 1);
  final ArrayImg<BitType, LongArray> bitImg = ArrayImgs.bits(dims);
  bitImg.setLinkedType(new BitType(bitImg));
  bitImg.cursor().next().set(true);
  return Views.extendBorder(bitImg);
}

相关文章