Search in sources :

Example 1 with Image

use of omero.model.Image in project imagej-omero by imagej.

the class DefaultOMEROSession method loadImage.

@Override
public Image loadImage(final OMEROFormat.Metadata meta) throws ServerError {
    // return cached Image if available
    Image image = meta.getImage();
    if (image != null)
        return image;
    final long imageID = meta.getImageID();
    if (imageID == 0)
        throw new IllegalArgumentException("Image ID is unset");
    // load the Image from the remote server
    final List<Long> ids = Arrays.asList(imageID);
    final List<Image> images = session.getContainerService().getImages("Image", ids, null);
    if (images == null || images.isEmpty()) {
        throw new IllegalArgumentException("Invalid image ID: " + imageID);
    }
    image = images.get(0);
    meta.setImage(image);
    return image;
}
Also used : RLong(omero.RLong) Image(omero.model.Image)

Example 2 with Image

use of omero.model.Image 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

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