protected static double[] createArray(final Interval interval, final double sigma) {
    final double[] sigmas = new double[interval.numDimensions()];

    for (int d = 0; d < interval.numDimensions(); ++d) sigmas[d] = sigma;

    return sigmas;
  }
예제 #2
0
  /**
   * Test whether the {@code containing} interval completely contains the {@code contained}
   * interval.
   *
   * <p>TODO: move to {@link Intervals}
   *
   * @param containing
   * @param contained
   * @return
   */
  public static final boolean contains(final Interval containing, final Interval contained) {
    assert containing.numDimensions() == contained.numDimensions();

    final int n = containing.numDimensions();
    for (int d = 0; d < n; ++d) {
      if (containing.min(d) > contained.min(d) || containing.max(d) < contained.max(d))
        return false;
    }
    return true;
  }
예제 #3
0
  public static String printInterval(final Interval interval) {
    String out = "(Interval empty)";

    if (interval == null || interval.numDimensions() == 0) return out;

    out = "[" + interval.min(0);

    for (int i = 1; i < interval.numDimensions(); i++) out += ", " + interval.min(i);

    out += "] -> [" + interval.max(0);

    for (int i = 1; i < interval.numDimensions(); i++) out += ", " + interval.max(i);

    out += "], dimensions (" + interval.dimension(0);

    for (int i = 1; i < interval.numDimensions(); i++) out += ", " + interval.dimension(i);

    out += ")";

    return out;
  }
  /**
   * Walk through an Interval on an Img using a LocalizingCursor, localizing on every step.
   *
   * @param img
   * @param interval
   */
  protected static void localizingWalkThrough(final Img<IntType> img, final Interval interval) {
    final Cursor<IntType> c = Views.interval(img, interval).localizingCursor();

    final long[] pos = new long[interval.numDimensions()];

    int i = 0;
    while (c.hasNext()) {
      c.fwd();
      i += c.get().get();
      c.localize(pos);
    }
    j = (int) pos[0] + i;
  }
  private long numPixels(final Interval i) {
    assert i != null;

    long[] dims = new long[i.numDimensions()];
    i.dimensions(dims);

    long acc = 1;
    for (long l : dims) {
      acc *= l;
    }

    return acc;
  }
예제 #6
0
 /**
  * Create a long[] with the min coordinates of an {@link Interval}.
  *
  * <p>Keep in mind that creating arrays wildly is not good practice and consider using the
  * interval directly.
  *
  * @param interval
  * @return dimensions of the interval as a new long[]
  */
 public static final long[] intervalMin(final Interval interval) {
   final long[] min = new long[interval.numDimensions()];
   interval.min(min);
   return min;
 }
예제 #7
0
 /**
  * Create a long[] with the max coordinates of an {@link Interval}.
  *
  * <p>Keep in mind that creating arrays wildly is not good practice and consider using the
  * interval directly.
  *
  * @param interval
  * @return dimensions of the interval as a new long[]
  */
 public static final long[] intervalMax(final Interval interval) {
   final long[] max = new long[interval.numDimensions()];
   interval.max(max);
   return max;
 }
예제 #8
0
 /**
  * Create a long[] with the dimensions of an {@link Interval}.
  *
  * <p>Keep in mind that creating arrays wildly is not good practice and consider using the
  * interval directly.
  *
  * @param interval
  * @return dimensions of the interval as a new long[]
  */
 public static final long[] intervalDimensions(final Interval interval) {
   final long[] dimensions = new long[interval.numDimensions()];
   interval.dimensions(dimensions);
   return dimensions;
 }
예제 #9
0
 private long[] resultDims(final Interval src) {
   long[] dims = new long[src.numDimensions()];
   src.dimensions(dims);
   return dims;
 }
 @Override
 public int numDimensions() {
   return interval.numDimensions();
 }