Search in sources :

Example 1 with ImageMetadata

use of io.scif.ImageMetadata in project imagej-omero by imagej.

the class OMEROFormat method rasterToPosition.

/**
 * Gets the position per axis of the given plane index, reordering the axes as
 * requested.
 *
 * @param imageIndex TODO
 * @param planeIndex The plane to convert to axis coordinates.
 * @param metadata TODO
 * @param axisTypes The axes whose coordinates are desired. TODO if a type is
 *          given that is not part of the image, this method gives -1 for that
 *          axis's position.
 * @return TODO
 */
public static long[] rasterToPosition(final int imageIndex, final long planeIndex, final Metadata metadata, final AxisType... axisTypes) {
    // FIXME: Move this into SCIFIO core in a utility class.
    final long[] nPos = FormatTools.rasterToPosition(imageIndex, planeIndex, metadata);
    final ImageMetadata imageMeta = metadata.get(imageIndex);
    final int planarAxisCount = imageMeta.getPlanarAxisCount();
    final long[] kPos = new long[axisTypes.length];
    for (int i = 0; i < kPos.length; i++) {
        final int index = imageMeta.getAxisIndex(axisTypes[i]);
        kPos[i] = index < 0 ? -1 : nPos[index - planarAxisCount];
    }
    return kPos;
}
Also used : ImageMetadata(io.scif.ImageMetadata)

Example 2 with ImageMetadata

use of io.scif.ImageMetadata in project imagej-omero by imagej.

the class DefaultOMEROSession method createImage.

// -- Helper methods --
private ImageData createImage(final OMEROFormat.Metadata meta) throws ServerError, FormatException {
    // create a new Image
    final ImageMetadata imageMeta = meta.get(0);
    final int xLen = axisLength(imageMeta, Axes.X);
    final int yLen = axisLength(imageMeta, Axes.Y);
    final int zLen = axisLength(imageMeta, Axes.Z);
    final int tLen = axisLength(imageMeta, Axes.TIME);
    final int cLen = axisLength(imageMeta, Axes.CHANNEL);
    final int sizeX = xLen == 0 ? 1 : xLen;
    final int sizeY = yLen == 0 ? 1 : yLen;
    final int sizeZ = zLen == 0 ? 1 : zLen;
    final int sizeT = tLen == 0 ? 1 : tLen;
    final int sizeC = cLen == 0 ? 1 : cLen;
    final List<Integer> channelList = new ArrayList<Integer>(sizeC);
    for (int c = 0; c < sizeC; c++) {
        // TODO: Populate actual emission wavelengths?
        channelList.add(c);
    }
    final int pixelType = imageMeta.getPixelType();
    final PixelsType pixelsType = getPixelsType(pixelType);
    final String name = meta.getName();
    final String description = meta.getName();
    final RLong id = session.getPixelsService().createImage(sizeX, sizeY, sizeZ, sizeT, channelList, pixelsType, name, description);
    if (id == null)
        throw new FormatException("Cannot create image");
    // retrieve the newly created Image
    final List<Image> results = session.getContainerService().getImages(Image.class.getName(), Arrays.asList(id.getValue()), null);
    return new ImageData(results.get(0));
}
Also used : ImageMetadata(io.scif.ImageMetadata) ImageData(omero.gateway.model.ImageData) ArrayList(java.util.ArrayList) PixelsType(omero.model.PixelsType) RLong(omero.RLong) Image(omero.model.Image) FormatException(io.scif.FormatException)

Aggregations

ImageMetadata (io.scif.ImageMetadata)2 FormatException (io.scif.FormatException)1 ArrayList (java.util.ArrayList)1 RLong (omero.RLong)1 ImageData (omero.gateway.model.ImageData)1 Image (omero.model.Image)1 PixelsType (omero.model.PixelsType)1