예제 #1
0
 /** Returns true if the provided axes correspond to a complete image plane */
 public static boolean wholePlane(
     final int imageIndex, final Metadata meta, final long[] planeMin, final long[] planeMax) {
   final boolean wholePlane = wholeRow(imageIndex, meta, planeMin, planeMax);
   final int yIndex = meta.get(imageIndex).getAxisIndex(Axes.Y);
   return wholePlane
       && planeMin[yIndex] == 0
       && planeMax[yIndex] == meta.get(imageIndex).getAxisLength(Axes.Y);
 }
예제 #2
0
  /**
   * Iterates over the provided Metadata's planar axes, replacing any instances of axes with the
   * paired values.
   */
  public static long[] modifyPlanar(
      final int imageIndex, final Metadata meta, final AxisValue... axes) {
    final long[] planarAxes = meta.get(imageIndex).getAxesLengthsPlanar();

    for (final AxisValue v : axes) {
      planarAxes[meta.get(imageIndex).getAxisIndex(v.getType())] = v.getLength();
    }

    return planarAxes;
  }
예제 #3
0
  /** Returns true if the provided axes correspond to a complete image row */
  public static boolean wholeRow(
      final int imageIndex, final Metadata meta, final long[] planeMin, final long[] planeMax) {
    boolean wholeRow = true;
    final int yIndex = meta.get(imageIndex).getAxisIndex(Axes.Y);

    for (int i = 0; wholeRow && i < planeMin.length; i++) {
      if (i == yIndex) continue;
      if (planeMin[i] != 0 || planeMax[i] != meta.get(imageIndex).getAxisLength(i))
        wholeRow = false;
    }

    return wholeRow;
  }
예제 #4
0
    @Override
    public void populateImageMetadata() {
      // clears existing metadata
      createImageMetadata(0);

      // copies the delegate's image metadata
      for (final ImageMetadata meta : metadata.getAll()) add(meta);
    }
예제 #5
0
  /** Replaces the first values.length of the provided Metadata's planar axes with the values. */
  public static long[] modifyPlanar(
      final int imageIndex, final Metadata meta, final long... values) {
    final AxisValue[] axes = new AxisValue[values.length];
    final List<CalibratedAxis> axisTypes = meta.get(imageIndex).getAxes();

    for (int i = 0; i < axes.length && i < axisTypes.size(); i++) {
      axes[i] = new AxisValue(axisTypes.get(i).type(), values[i]);
    }

    return modifyPlanar(imageIndex, meta, axes);
  }
예제 #6
0
  /**
   * Checks whether the given metadata object has the minimum metadata populated to successfully
   * describe the nth Image.
   *
   * @throws FormatException if there is a missing metadata field, or the metadata object is
   *     uninitialized
   */
  public static void verifyMinimumPopulated(
      final Metadata src, final RandomAccessOutputStream out, final int imageIndex)
      throws FormatException {
    if (src == null) {
      throw new FormatException("Metadata object is null; " + "call Writer.setMetadata() first");
    }

    if (out == null) {
      throw new FormatException(
          "RandomAccessOutputStream object is null; "
              + "call Writer.setSource(<String/File/RandomAccessOutputStream>) first");
    }

    if (src.get(imageIndex).getAxes().size() == 0) {
      throw new FormatException("Axiscount #" + imageIndex + " is 0");
    }
  }
예제 #7
0
    @Override
    public void close(final boolean fileOnly) throws IOException {
      for (final String name : mappedFiles) {
        final IRandomAccess handle = locationService.getMappedFile(name);
        locationService.mapFile(name, null);
        if (handle != null) {
          handle.close();
        }
      }
      mappedFiles.clear();

      super.close(fileOnly);

      if (metadata != null) metadata.close(fileOnly);
      if (!fileOnly) metadata = null;

      mappedFiles = new ArrayList<String>();
    }
예제 #8
0
    public void setMetadata(final io.scif.Metadata m) throws IOException {
      if (metadata != null) metadata.close();

      metadata = m;
    }
예제 #9
0
 @Override
 public ColorTable getColorTable(final int imageIndex, final long planeIndex) {
   if (HasColorTable.class.isAssignableFrom(metadata.getClass()))
     return ((HasColorTable) metadata).getColorTable(imageIndex, planeIndex);
   return null;
 }