Search in sources :

Example 11 with MetadataRetrieve

use of loci.formats.meta.MetadataRetrieve in project bioformats by openmicroscopy.

the class LociFunctions method getPixelsPhysicalSizeY.

public void getPixelsPhysicalSizeY(Double[] sizeY) {
    int imageIndex = r.getSeries();
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length y = retrieve.getPixelsPhysicalSizeY(imageIndex);
    if (y != null) {
        sizeY[0] = y.value(UNITS.MICROMETER).doubleValue();
    }
    if (sizeY[0] == null)
        sizeY[0] = new Double(Double.NaN);
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 12 with MetadataRetrieve

use of loci.formats.meta.MetadataRetrieve in project bioformats by openmicroscopy.

the class LociFunctions method getPlanePositionZ.

public void getPlanePositionZ(Double[] positionZ, Double no) {
    int imageIndex = r.getSeries();
    int planeIndex = getPlaneIndex(r, no.intValue());
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length val = null;
    if (planeIndex >= 0) {
        val = retrieve.getPlanePositionZ(imageIndex, planeIndex);
    }
    if (val == null) {
        val = new Length(Double.NaN, UNITS.REFERENCEFRAME);
    }
    positionZ[0] = val == null ? Double.NaN : val.value(UNITS.REFERENCEFRAME).doubleValue();
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 13 with MetadataRetrieve

use of loci.formats.meta.MetadataRetrieve in project bioformats by openmicroscopy.

the class LociFunctions method getPlanePositionX.

public void getPlanePositionX(Double[] positionX, Double no) {
    int imageIndex = r.getSeries();
    int planeIndex = getPlaneIndex(r, no.intValue());
    MetadataRetrieve retrieve = (MetadataRetrieve) r.getMetadataStore();
    Length val = null;
    if (planeIndex >= 0) {
        val = retrieve.getPlanePositionX(imageIndex, planeIndex);
    }
    positionX[0] = val == null ? Double.NaN : val.value(UNITS.REFERENCEFRAME).doubleValue();
}
Also used : Length(ome.units.quantity.Length) MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 14 with MetadataRetrieve

use of loci.formats.meta.MetadataRetrieve in project bioformats by openmicroscopy.

the class FormatWriter method getPlaneCount.

/**
 * Retrieve the total number of planes in given series.
 */
protected int getPlaneCount(int series) {
    MetadataRetrieve r = getMetadataRetrieve();
    int z = r.getPixelsSizeZ(series).getValue().intValue();
    int t = r.getPixelsSizeT(series).getValue().intValue();
    int c = r.getPixelsSizeC(series).getValue().intValue();
    c /= r.getChannelSamplesPerPixel(series, 0).getValue().intValue();
    return z * c * t;
}
Also used : MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Example 15 with MetadataRetrieve

use of loci.formats.meta.MetadataRetrieve in project bioformats by openmicroscopy.

the class FormatWriter method seekToPlaneOffset.

/**
 * Seek to the given (x, y) coordinate of the image that starts at
 * the given offset.
 */
protected void seekToPlaneOffset(long baseOffset, int x, int y) throws IOException {
    out.seek(baseOffset);
    MetadataRetrieve r = getMetadataRetrieve();
    int samples = getSamplesPerPixel();
    int pixelType = FormatTools.pixelTypeFromString(r.getPixelsType(series).toString());
    int bpp = FormatTools.getBytesPerPixel(pixelType);
    if (interleaved)
        bpp *= samples;
    int sizeX = r.getPixelsSizeX(series).getValue().intValue();
    out.skipBytes(bpp * (y * sizeX + x));
}
Also used : MetadataRetrieve(loci.formats.meta.MetadataRetrieve)

Aggregations

MetadataRetrieve (loci.formats.meta.MetadataRetrieve)64 FormatException (loci.formats.FormatException)11 MetadataStore (loci.formats.meta.MetadataStore)11 Length (ome.units.quantity.Length)10 ServiceFactory (loci.common.services.ServiceFactory)8 DependencyException (loci.common.services.DependencyException)7 OMEXMLService (loci.formats.services.OMEXMLService)6 RandomAccessInputStream (loci.common.RandomAccessInputStream)5 Time (ome.units.quantity.Time)5 PositiveInteger (ome.xml.model.primitives.PositiveInteger)5 ServiceException (loci.common.services.ServiceException)4 MissingLibraryException (loci.formats.MissingLibraryException)4 Test (org.testng.annotations.Test)4 IndexColorModel (java.awt.image.IndexColorModel)3 Location (loci.common.Location)3 RandomAccessOutputStream (loci.common.RandomAccessOutputStream)3 ImageReader (loci.formats.ImageReader)3 BufferedImage (java.awt.image.BufferedImage)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 File (java.io.File)2