Package net.imglib2.roi

Examples of net.imglib2.roi.RegionOfInterest


  // this is the constructor if you want it to be a variable
  public GenericShortType( final short value )
  {
    img = null;
    dataAccess = new ShortArray( 1 );
    setValue( value );
  }
View Full Code Here


  }

  @Override
  public CellImg< T, ShortArray, DefaultCell< ShortArray > > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel )
  {
    return createInstance( new ShortArray( 1 ), dimensions, entitiesPerPixel );
  }
View Full Code Here

  }

  @Override
  public NativeImg< T, ShortArray > createShortInstance( final long[] dimensions, final Fraction entitiesPerPixel )
  {
    return new PlanarImg< T, ShortArray >( new ShortArray( 1 ), dimensions, entitiesPerPixel );
  }
View Full Code Here

  /**
   * A test of a ROI that has no pixel iterator.
   */
  @Test
  public final void testNonIterableROI() {
    final RegionOfInterest roi = new AbstractRegionOfInterest(2) {
      private double center_x = 25.0;
      private double center_y = 10.0;
      public boolean contains(double[] position) {
        // Mandelbrot set goes from x = -2.5 to 1, y = -1 to 1
        // so we add 2.5, 1 and multiply each by 10.
        final double x0 = position[0] * 10 + center_x;
        final double y0 = position[1] * 10 + center_y;
        double x = x0;
        double y = y0;
        for (int i=0;i < 100; i++) {
          if (x*x + y*y >= 4) return false;
          final double xnext = x*x - y*y + x0;
          y = 2 * x * y + y0;
          x = xnext;
        }
        return true;
      }

      public void move(double displacement, int d) {
        if (d == 0)
          center_x += displacement;
        else
          center_y += displacement;
      }

      @Override
      protected void getRealExtrema(double[] minima, double[] maxima) {
        minima[0] = center_x - 25.0;
        minima[1] = center_y - 10.0;
        maxima[0] = center_x + 10.0;
        maxima[1] = center_y + 10.0;
      }};
    Overlay o = new AbstractROIOverlay<RegionOfInterest>(context.getContext(), roi) {

      /* (non-Javadoc)
       * @see imagej.data.overlay.Overlay#move(double[])
       */
      public void move(double[] deltas) {
        roi.move(deltas);
      }
    };
    Dataset dataset = getDatasetService().create(new long [] { 30, 30 }, "Foo", new AxisType [] { Axes.X, Axes.Y }, 8, true, false);
    Display<?> display = getDisplayService().createDisplay(getImageDisplayService().createDataView(dataset));
    assertTrue(display instanceof ImageDisplay);
    ImageDisplay iDisplay = (ImageDisplay)display;
    getOverlayService().addOverlays(iDisplay, Collections.singletonList((Overlay)o));
    for (DataView v:iDisplay) {
      v.setSelected(true);
    }
    Img<BitType> mask = OverlayUtils.extractMask(iDisplay);
    assertNotNull(mask);
    Cursor<BitType> c = mask.cursor();
    double [] position = new double [2];
    while(c.hasNext()) {
      BitType t = c.next();
      position[1] = c.getDoublePosition(0);
      position[0] = c.getDoublePosition(1);
      assertEquals(t.get(), roi.contains(position));
    }
  }
View Full Code Here

          dAxes[i] = dAxes[j];
          dAxes[j] = temp;
        }
      }
      adapter = Views.translate(adapter, offset);
      RegionOfInterest roi = overlay.getRegionOfInterest();
      if (roi instanceof IterableRegionOfInterest) {
        /*
         * Yay! We can iterate over the pixels to turn each of them on.
         */
        IterableInterval<BitType> ii =
          ((IterableRegionOfInterest) roi).getIterableIntervalOverROI(adapter);
        Cursor<BitType> c = ii.cursor();
        while(c.hasNext()){
          c.next().set(true);
        }
      } else {
        /*
         * Boo! We have to sample from the ROI.
         */
        RealRandomAccess<BitType> roiAccess = roi.realRandomAccess();
        Cursor<BitType> c = Views.iterable(adapter).cursor();
        while(c.hasNext()) {
          BitType t = c.next();
          roiAccess.setPosition(c);
          t.set(roiAccess.get().get());
View Full Code Here

        }

        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

      else
      {
        component[ e ] = e;
      }
    }
    final MixedTransform t = new MixedTransform( n, n );
    t.setComponentMapping( component );
    t.setComponentInversion( inv );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here

    final int[] component = new int[ n ];
    for ( int e = 0; e < n; ++e )
      component[ e ] = e;
    component[ fromAxis ] = toAxis;
    component[ toAxis ] = fromAxis;
    final MixedTransform t = new MixedTransform( n, n );
    t.setComponentMapping( component );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here

   *            resulting view.
   */
  public static < T > MixedTransformView< T > translate( final RandomAccessible< T > randomAccessible, final long... translation )
  {
    final int n = randomAccessible.numDimensions();
    final MixedTransform t = new MixedTransform( n, n );
    t.setInverseTranslation( translation );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here

   *            origin of resulting view.
   */
  public static < T > MixedTransformView< T > offset( final RandomAccessible< T > randomAccessible, final long... offset )
  {
    final int n = randomAccessible.numDimensions();
    final MixedTransform t = new MixedTransform( n, n );
    t.setTranslation( offset );
    return new MixedTransformView< T >( randomAccessible, t );
  }
View Full Code Here

TOP

Related Classes of net.imglib2.roi.RegionOfInterest

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.