Exemple #1
0
  private void processPlane(
      final Position planePos, final long rx, final long ry, final long rw, final long rh) {

    final long[] inputPosition = new long[planePos.numDimensions() + 2];
    final long[] outputPosition = new long[planePos.numDimensions() + 2];

    for (int i = 2; i < inputPosition.length; i++)
      inputPosition[i] = planePos.getLongPosition(i - 2);

    for (long y = ry; y < ry + rh; y++) {
      inputPosition[1] = y;

      for (long x = rx; x < rx + rw; x++) {
        inputPosition[0] = x;

        flipper.calcOutputPosition(inputDimensions, inputPosition, outputPosition);

        inputAccessor.setPosition(inputPosition);
        outputAccessor.setPosition(outputPosition);

        final double value = inputAccessor.get().getRealDouble();

        outputAccessor.get().setReal(value);
      }
    }
  }
Exemple #2
0
  /** Makes sure input is okay and creates output image */
  @Override
  public boolean checkInput() {
    final Img inputImage = dataset.getImgPlus(); // TODO - raw type required
    // here

    inputDimensions = new long[inputImage.numDimensions()];

    inputImage.dimensions(inputDimensions);

    final long[] outputDimensions = flipper.calcOutputDimensions(inputDimensions);

    outputImage = inputImage.factory().create(outputDimensions, inputImage.firstElement());

    return true;
  }
Exemple #3
0
  /** Fills the output image from the input image doing coordinate transformations as needed */
  @Override
  public boolean process() {
    final Img<? extends RealType<?>> inputImage = dataset.getImgPlus();

    inputAccessor = inputImage.randomAccess();
    outputAccessor = outputImage.randomAccess();

    final long width = inputDimensions[0];
    final long height = inputDimensions[1];

    long rx, ry, rw, rh;

    if (flipper.isShapePreserving() && (bounds.width > 0) && (bounds.height > 0)) {
      rx = (long) bounds.x;
      ry = (long) bounds.y;
      rw = (long) bounds.width;
      rh = (long) bounds.height;
    } else {
      rx = 0;
      ry = 0;
      rw = width;
      rh = height;
    }

    final long[] planeDims = new long[inputImage.numDimensions() - 2];
    for (int i = 0; i < planeDims.length; i++) planeDims[i] = inputDimensions[i + 2];
    final Extents extents = new Extents(planeDims);
    final Position planePos = extents.createPosition();
    if (planeDims.length == 0) { // 2d Dataset
      processPlane(planePos, rx, ry, rw, rh);
    } else { // more than two dimensions
      while (planePos.hasNext()) {
        planePos.fwd();
        processPlane(planePos, rx, ry, rw, rh);
      }
    }
    return true;
  }