Examples of FloatType


Examples of net.imglib2.type.numeric.real.FloatType

  @Test
  public void testFloatNoTails()
  {
    long binPos;
    final FloatType tmp = new FloatType();
    final Real1dBinMapper< FloatType > binMapper =
        new Real1dBinMapper< FloatType >( 0.0, 100.0, 100, false );
    assertEquals( 100, binMapper.getBinCount() );
    for ( double i = 0; i <= 100; i += 0.125 )
    {
      tmp.setReal( i );
      binPos = binMapper.map( tmp );
      double expectedBin = Math.floor( i );
      if ( i == 100.0 )
        expectedBin--;
      assertEquals( expectedBin, binPos, 0 );
      binMapper.getLowerBound( binPos, tmp );
      assertEquals( expectedBin, tmp.getRealDouble(), 0.0 );
      binMapper.getUpperBound( binPos, tmp );
      assertEquals( expectedBin + 1, tmp.getRealDouble(), 0.0 );
      binMapper.getCenterValue( binPos, tmp );
      assertEquals( expectedBin + 0.5, tmp.getRealDouble(), 0.0 );
    }
    tmp.setReal( -0.0001 );
    assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) );
    tmp.setReal( 100.0001 );
    assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  @Test
  public void testFloatTails()
  {
    long binPos;
    final FloatType tmp = new FloatType();
    final Real1dBinMapper< FloatType > binMapper =
        new Real1dBinMapper< FloatType >( 0.0, 100.0, 102, true );
    assertEquals( 102, binMapper.getBinCount() );
    for ( double i = 0; i <= 100; i += 0.125 )
    {
      tmp.setReal( i );
      binPos = binMapper.map( tmp );
      double expectedBin = Math.floor( i ) + 1;
      if ( i == 100.0 )
        expectedBin--;
      assertEquals( expectedBin, binPos, 0 );
      binMapper.getLowerBound( binPos, tmp );
      assertEquals( expectedBin - 1, tmp.getRealDouble(), 0.0 );
      binMapper.getUpperBound( binPos, tmp );
      assertEquals( expectedBin, tmp.getRealDouble(), 0.0 );
      binMapper.getCenterValue( binPos, tmp );
      assertEquals( expectedBin - 0.5, tmp.getRealDouble(), 0.0 );
    }
    tmp.setReal( -0.0001 );
    assertEquals( 0, binMapper.map( tmp ) );
    tmp.setReal( 100.0001 );
    assertEquals( 101, binMapper.map( tmp ) );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  @Test
  public void testBinBoundariesTails()
  {
    long pos;
    final FloatType tmp = new FloatType();
    Real1dBinMapper< FloatType > binMapper;

    pos = 0;
    binMapper = new Real1dBinMapper< FloatType >( 0.0, 4.0, 4, true );
    binMapper.getLowerBound( pos, tmp );
    assertEquals( Double.NEGATIVE_INFINITY, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 0, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesUpperBound( pos ) );

    pos = 1;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 0, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 2, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesUpperBound( pos ) );

    pos = 2;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 2, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 4, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesUpperBound( pos ) );

    pos = 3;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 4, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( Double.POSITIVE_INFINITY, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesUpperBound( pos ) );

    tmp.setReal( -0.001 );
    pos = binMapper.map( tmp );
    assertEquals( 0, pos );

    tmp.setReal( 4.001 );
    pos = binMapper.map( tmp );
    assertEquals( 3, pos );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  @Test
  public void testBinBoundariesNoTails()
  {
    long pos;
    final FloatType tmp = new FloatType();
    Real1dBinMapper< FloatType > binMapper;

    binMapper = new Real1dBinMapper< FloatType >( 0.0, 4.0, 4, false );
    pos = 0;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 0, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 1, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesUpperBound( pos ) );

    pos = 1;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 1, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 2, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesUpperBound( pos ) );

    pos = 2;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 2, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 3, tmp.getRealDouble(), 0 );
    assertFalse( binMapper.includesUpperBound( pos ) );

    pos = 3;
    binMapper.getLowerBound( pos, tmp );
    assertEquals( 3, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesLowerBound( pos ) );
    binMapper.getUpperBound( pos, tmp );
    assertEquals( 4, tmp.getRealDouble(), 0 );
    assertTrue( binMapper.includesUpperBound( pos ) );

    tmp.setReal( -0.001 );
    assertEquals( Long.MIN_VALUE, binMapper.map( tmp ) );

    tmp.setReal( 4.001 );
    assertEquals( Long.MAX_VALUE, binMapper.map( tmp ) );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  @Test
  public void testEmptyMapper()
  {
    long pos;
    final FloatType tmp = new FloatType();
    Real1dBinMapper< FloatType > binMapper;

    binMapper = new Real1dBinMapper< FloatType >( 0.0, 0.0, 4, false );
    assertNotNull( binMapper );
    tmp.set( 0 );
    pos = binMapper.map( tmp );
    assertEquals( 0, pos );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  /**
   * Generate a test image
   */
  protected Img< FloatType > makeTestImage3D( final long cubeLength )
  {
    return makeImage( new FloatType(), new TestGenerator( cubeLength ), new long[] { cubeLength, cubeLength, cubeLength } );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  /**
   * Generate a test image
   */
  protected Img< FloatType > makeSinglePixel3D( final long cubeLength, final long x, final long y, final long z )
  {
    return makeImage( new FloatType(), new SinglePixel3D( x, y, z ), new long[] { cubeLength, cubeLength, cubeLength } );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  }

  @Test
  public void testFloatDefaultCellSize()
  {
    testDefaultCellSize( new FloatType() );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

  }

  @Test
  public void testFloatDefaultCellDimensions()
  {
    testDefaultCellDimensions( new FloatType() );
  }
View Full Code Here

Examples of net.imglib2.type.numeric.real.FloatType

    { 5, 4, 3 },
    { 2, 1, 0 }
    } };
    for ( int i = 0; i < offsets.length; i++ )
    {
      final Img< FloatType > img = new ArrayImgFactory< FloatType >().create( new long[] { 3, 3 }, new FloatType() );
      ImgUtil.copy( input, offsets[ i ], strides[ i ], img );
      final RandomAccess< FloatType > ra = img.randomAccess();
      final long[] location = new long[ 2 ];
      for ( int x = 0; x < 3; x++ )
      {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.