Package net.imglib2.transform.integer

Examples of net.imglib2.transform.integer.SequentializeTransform


   */
  public static < T > MixedTransformView< T > addDimension( final RandomAccessible< T > randomAccessible )
  {
    final int m = randomAccessible.numDimensions();
    final int n = m + 1;
    final MixedTransform t = new MixedTransform( n, m );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here


  public static < T > MixedTransformView< T > invertAxis( final RandomAccessible< T > randomAccessible, final int d )
  {
    final int n = randomAccessible.numDimensions();
    final boolean[] inv = new boolean[ n ];
    inv[ d ] = true;
    final MixedTransform t = new MixedTransform( n, n );
    t.setComponentInversion( inv );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here

    }
    else
    {
      this.source = source;
      final int sourceDim = this.source.numDimensions();
      this.transformToSource = new MixedTransform( n, sourceDim );
      this.transformToSource.set( transformToSource );
    }

    fullViewRandomAccessible = null;
  }
View Full Code Here

  @Test
  public void test4Dto3DInverse()
  {
    final long[] dim = new long[] { 10, 20, 30, 40 };
    final SequentializeTransform t = new SequentializeTransform( dim, 3 );

    final long[] source = new long[ 4 ];
    final long[] target = new long[ 3 ];
    final long[] expectedSource = new long[ 4 ];

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    source[ 3 ] = 0;
    t.apply( source, target );
    for ( int d = 0; d < 4; ++d )
    {
      expectedSource[ d ] = source[ d ];
      source[ d ] = -1;
    }
    t.applyInverse( source, target );
    assertArrayEquals( expectedSource, source );

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    source[ 3 ] = 1;
    t.apply( source, target );
    for ( int d = 0; d < 4; ++d )
    {
      expectedSource[ d ] = source[ d ];
      source[ d ] = -1;
    }
    t.applyInverse( source, target );
    assertArrayEquals( expectedSource, source );

    source[ 0 ] = 9;
    source[ 1 ] = 4;
    source[ 2 ] = 2;
    source[ 3 ] = 3;
    t.apply( source, target );
    for ( int d = 0; d < 4; ++d )
    {
      expectedSource[ d ] = source[ d ];
      source[ d ] = -1;
    }
    t.applyInverse( source, target );
    assertArrayEquals( expectedSource, source );
  }
View Full Code Here

{
  @Test
  public void test2Dto1D()
  {
    final long[] dim = new long[] { 10, 20 };
    final SequentializeTransform t = new SequentializeTransform( dim, 1 );

    final long[] source = new long[ 2 ];
    final long[] target = new long[ 1 ];
    final long[] expectedTarget = new long[ 1 ];

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    expectedTarget[ 0 ] = 0;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 5;
    source[ 1 ] = 0;
    expectedTarget[ 0 ] = 5;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 5;
    source[ 1 ] = 1;
    expectedTarget[ 0 ] = 15;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );
  }
View Full Code Here

  @Test
  public void test3Dto1D()
  {
    final long[] dim = new long[] { 10, 20, 30 };
    final SequentializeTransform t = new SequentializeTransform( dim, 1 );

    final int[] source = new int[ 3 ];
    final int[] target = new int[ 1 ];
    final int[] expectedTarget = new int[ 1 ];

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    expectedTarget[ 0 ] = 0;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 5;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    expectedTarget[ 0 ] = 5;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 5;
    source[ 1 ] = 1;
    source[ 2 ] = 0;
    expectedTarget[ 0 ] = 15;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 5;
    source[ 1 ] = 4;
    source[ 2 ] = 3;
    expectedTarget[ 0 ] = 5 + 4 * 10 + 3 * 20 * 10;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );
  }
View Full Code Here

  @Test
  public void test4Dto3D()
  {
    final long[] dim = new long[] { 10, 20, 30, 40 };
    final SequentializeTransform t = new SequentializeTransform( dim, 3 );

    final long[] source = new long[ 4 ];
    final long[] target = new long[ 3 ];
    final long[] expectedTarget = new long[ 3 ];

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    source[ 3 ] = 0;
    expectedTarget[ 0 ] = source[ 0 ];
    expectedTarget[ 1 ] = source[ 1 ];
    expectedTarget[ 2 ] = 0;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 0;
    source[ 1 ] = 0;
    source[ 2 ] = 0;
    source[ 3 ] = 1;
    expectedTarget[ 0 ] = source[ 0 ];
    expectedTarget[ 1 ] = source[ 1 ];
    expectedTarget[ 2 ] = 30;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );

    source[ 0 ] = 9;
    source[ 1 ] = 4;
    source[ 2 ] = 2;
    source[ 3 ] = 3;
    expectedTarget[ 0 ] = source[ 0 ];
    expectedTarget[ 1 ] = source[ 1 ];
    expectedTarget[ 2 ] = 2 + 3 * 30;
    t.apply( source, target );
    assertArrayEquals( expectedTarget, target );
  }
View Full Code Here

        if ( iterableSource.supportsOptimizedCursor( interval ) )
          return new SubInterval( iterableSource );
      }
      else if ( transforms.size() == 1 && SlicingTransform.class.isInstance( transforms.get( 0 ) ) )
      {
        final SlicingTransform t = ( SlicingTransform ) transforms.get( 0 );
        final int m = t.numTargetDimensions();
        final int n = t.numSourceDimensions();

        // Check whether the slicing can be potentially optimized.
        boolean optimizable = true;

        // 1.) Slice dimensions must be mapped to a contiguous range of
        // target dimensions starting with dimension 0.
        int firstZeroDim = 0;
        for ( ; firstZeroDim < m && !t.getComponentZero( firstZeroDim ); ++firstZeroDim );
        for ( int d = firstZeroDim + 1; d < m && optimizable; ++d )
          if ( !t.getComponentZero( d ) )
            optimizable = false;

        // 2.) All slice dimensions must be mapped to a target dimension
        final int[] sourceComponent = new int[ n ];
        if ( optimizable )
        {
          Arrays.fill( sourceComponent, -1 );
          for ( int d = 0; d < m; ++d )
            if ( !t.getComponentZero( d ) )
              sourceComponent[ t.getComponentMapping( d ) ] = d;
          for ( int d = 0; d < n && optimizable; ++d )
            if ( sourceComponent[ d ] < 0 )
              optimizable = false;
        }

        if ( optimizable )
        {
//          System.out.println( "interval = " + Util.printInterval( interval ) );
          final Interval sliceInterval = t.transform( new BoundingBox( interval ) ).getInterval();
//          System.out.println( "transformed interval = " + Util.printInterval( sliceInterval ) );
          if ( iterableSource.supportsOptimizedCursor( sliceInterval ) )
          {
            // check for FlatIterationOrder
            boolean flat = FlatIterationOrder.class.isInstance( iterableSource.subIntervalIterationOrder( sliceInterval ) );
View Full Code Here

   * array will update the {@link Image}.
   */
  public ARGBScreenImage( final int width, final int height, final int[] data )
  {
    super( new IntArray( data ), new long[]{ width, height }, new Fraction() );
    setLinkedType( new ARGBType( this ) );
    this.data = data;

    final SampleModel sampleModel = ARGB_COLOR_MODEL.createCompatibleWritableRaster( 1, 1 ).getSampleModel()
        .createCompatibleSampleModel( width, height );
    final DataBuffer dataBuffer = new DataBufferInt( data, width * height, 0 );
View Full Code Here

      mapSingle( sourceRandomAccess, currentConverters[ 0 ] );
      return;
    }

    final Cursor< ARGBType > targetCursor = target.localizingCursor();
    final ARGBType bi = new ARGBType();

    while ( targetCursor.hasNext() )
    {
      targetCursor.fwd();
      sourceRandomAccess.setPosition( targetCursor.getLongPosition( 0 ), 0 );
      sourceRandomAccess.setPosition( targetCursor.getLongPosition( 1 ), 1 );
      int aSum = 0, rSum = 0, gSum = 0, bSum = 0;
      for ( int i = 0; i < size; i++ )
      {
        sourceRandomAccess.setPosition( currentPositions[ i ], dimIndex );
        currentConverters[ i ].convert( sourceRandomAccess.get(), bi );

        // accumulate converted result
        final int value = bi.get();
        final int a = ARGBType.alpha( value );
        final int r = ARGBType.red( value );
        final int g = ARGBType.green( value );
        final int b = ARGBType.blue( value );
        aSum += a;
View Full Code Here

TOP

Related Classes of net.imglib2.transform.integer.SequentializeTransform

Copyright © 2018 www.massapicom. 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.