Search in sources :

Example 31 with IFD

use of loci.formats.tiff.IFD in project bioformats by openmicroscopy.

the class ZeissLSMReader method getExtraSeries.

private int getExtraSeries(String file) throws FormatException, IOException {
    if (in != null)
        in.close();
    in = new RandomAccessInputStream(file, 16);
    boolean littleEndian = in.read() == TiffConstants.LITTLE;
    in.order(littleEndian);
    tiffParser = new TiffParser(in);
    IFD ifd = tiffParser.getFirstIFD();
    RandomAccessInputStream ras = getCZTag(ifd);
    if (ras == null)
        return 1;
    ras.order(littleEndian);
    ras.seek(264);
    dimensionP = ras.readInt();
    dimensionM = ras.readInt();
    ras.close();
    int nSeries = dimensionM * dimensionP;
    return nSeries <= 0 ? 1 : nSeries;
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser) RandomAccessInputStream(loci.common.RandomAccessInputStream)

Example 32 with IFD

use of loci.formats.tiff.IFD in project bioformats by openmicroscopy.

the class TCSReader method isThisType.

/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    // check for Leica TCS IFD directory entries
    TiffParser tp = new TiffParser(stream);
    IFD ifd = tp.getFirstIFD();
    if (ifd == null) {
        stream.seek(0);
        return stream.readString(6).equals("<Data>");
    }
    String document = ifd.getIFDTextValue(IFD.DOCUMENT_NAME);
    if (document == null)
        document = "";
    String software = ifd.getIFDTextValue(IFD.SOFTWARE);
    if (software == null)
        software = "";
    software = software.trim();
    return document.startsWith("CHANNEL") || software.startsWith("TCS");
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser)

Example 33 with IFD

use of loci.formats.tiff.IFD in project bioformats by openmicroscopy.

the class TrestleReader method isThisType.

/* @see loci.formats.IFormatReader#isThisType(RandomAccessInputStream) */
@Override
public boolean isThisType(RandomAccessInputStream stream) throws IOException {
    TiffParser parser = new TiffParser(stream);
    IFD ifd = parser.getFirstIFD();
    if (ifd == null)
        return false;
    String copyright = ifd.getIFDTextValue(IFD.COPYRIGHT);
    if (copyright == null)
        return false;
    return copyright.indexOf("Trestle Corp.") >= 0;
}
Also used : IFD(loci.formats.tiff.IFD) TiffParser(loci.formats.tiff.TiffParser)

Example 34 with IFD

use of loci.formats.tiff.IFD in project bioformats by openmicroscopy.

the class TrestleReader method initStandardMetadata.

// -- Internal BaseTiffReader API methods --
/* @see loci.formats.in.BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
    super.initStandardMetadata();
    ifds = tiffParser.getIFDs();
    for (IFD ifd : ifds) {
        tiffParser.fillInIFD(ifd);
    }
    String comment = ifds.get(0).getComment();
    String[] values = comment.split(";");
    for (String v : values) {
        int eq = v.indexOf('=');
        if (eq < 0)
            continue;
        String key = v.substring(0, eq).trim();
        String value = v.substring(eq + 1).trim();
        addGlobalMeta(key, value);
        if (key.equals("OverlapsXY")) {
            String[] overlapValues = value.split(" ");
            overlaps = new int[ifds.size() * 2];
            for (int i = 0; i < overlapValues.length; i++) {
                overlaps[i] = Integer.parseInt(overlapValues[i]);
            }
        }
    }
    int seriesCount = ifds.size();
    core.clear();
    for (int i = 0; i < seriesCount; i++) {
        CoreMetadata c = new CoreMetadata();
        if (i == 0 && !hasFlattenedResolutions()) {
            c.resolutionCount = seriesCount;
        }
        core.add(c);
    }
    for (int s = 0; s < core.size(); s++) {
        CoreMetadata ms = core.get(s);
        IFD ifd = ifds.get(s);
        PhotoInterp p = ifd.getPhotometricInterpretation();
        int samples = ifd.getSamplesPerPixel();
        ms.rgb = samples > 1 || p == PhotoInterp.RGB;
        long numTileRows = ifd.getTilesPerColumn() - 1;
        long numTileCols = ifd.getTilesPerRow() - 1;
        int overlapX = overlaps[s * 2];
        int overlapY = overlaps[s * 2 + 1];
        ms.sizeX = (int) (ifd.getImageWidth() - (numTileCols * overlapX));
        ms.sizeY = (int) (ifd.getImageLength() - (numTileRows * overlapY));
        ms.sizeZ = 1;
        ms.sizeT = 1;
        ms.sizeC = ms.rgb ? samples : 1;
        ms.littleEndian = ifd.isLittleEndian();
        ms.indexed = p == PhotoInterp.RGB_PALETTE && (get8BitLookupTable() != null || get16BitLookupTable() != null);
        ms.imageCount = 1;
        ms.pixelType = ifd.getPixelType();
        ms.metadataComplete = true;
        ms.interleaved = false;
        ms.falseColor = false;
        ms.dimensionOrder = "XYCZT";
        ms.thumbnail = s > 0;
    }
    // look for all of the other associated metadata files
    files = new ArrayList<String>();
    Location baseFile = new Location(currentId).getAbsoluteFile();
    Location parent = baseFile.getParentFile();
    String name = baseFile.getName();
    if (name.indexOf('.') >= 0) {
        name = name.substring(0, name.indexOf('.') + 1);
    }
    roiFile = new Location(parent, name + "ROI").getAbsolutePath();
    roiDrawFile = new Location(parent, name + "ROI-draw").getAbsolutePath();
    String[] list = parent.list(true);
    for (String f : list) {
        if (!f.equals(baseFile.getName())) {
            files.add(new Location(parent, f).getAbsolutePath());
        }
    }
}
Also used : IFD(loci.formats.tiff.IFD) PhotoInterp(loci.formats.tiff.PhotoInterp) CoreMetadata(loci.formats.CoreMetadata) Location(loci.common.Location)

Example 35 with IFD

use of loci.formats.tiff.IFD in project bioformats by openmicroscopy.

the class VectraReader method initStandardMetadata.

// -- Internal BaseTiffReader API methods --
/* @see loci.formats.BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
    super.initStandardMetadata();
    ifds = tiffParser.getIFDs();
    thumbnailIFDs = null;
    for (IFD ifd : ifds) {
        tiffParser.fillInIFD(ifd);
    }
    // count number of channels
    CoreMetadata m = core.get(0);
    m.sizeC = 1;
    if (ifds.get(0).getSamplesPerPixel() == 1) {
        long width = ifds.get(0).getImageWidth();
        long height = ifds.get(0).getImageLength();
        int ifd = 1;
        while (ifds.get(ifd).getImageWidth() == width && ifds.get(ifd).getImageLength() == height) {
            m.sizeC++;
            ifd++;
        }
    }
    for (int start = m.sizeC + 1; start < ifds.size(); start += m.sizeC) {
        IFD ifd = ifds.get(start);
        if (ifd.getIFDIntValue(IFD.NEW_SUBFILE_TYPE) == 1) {
            pyramidDepth++;
        } else
            break;
    }
    int coreSize = ifds.size() - (pyramidDepth * (m.sizeC - 1));
    // repopulate core metadata
    core.clear();
    for (int s = 0; s < coreSize; s++) {
        CoreMetadata ms = new CoreMetadata(m);
        if (s == 0) {
            ms.resolutionCount = pyramidDepth;
        }
        core.add(ms);
    }
    for (int s = 0; s < core.size(); s++) {
        CoreMetadata ms = core.get(s);
        int index = getIFDIndex(s, 0);
        IFD ifd = ifds.get(index);
        PhotoInterp p = ifd.getPhotometricInterpretation();
        int samples = ifd.getSamplesPerPixel();
        ms.rgb = samples > 1 || p == PhotoInterp.RGB;
        ms.sizeX = (int) ifd.getImageWidth();
        ms.sizeY = (int) ifd.getImageLength();
        ms.sizeZ = 1;
        ms.sizeT = 1;
        if (ms.rgb) {
            ms.sizeC = samples;
        }
        ms.littleEndian = ifd.isLittleEndian();
        ms.indexed = p == PhotoInterp.RGB_PALETTE && (get8BitLookupTable() != null || get16BitLookupTable() != null);
        ms.imageCount = ms.sizeC / samples;
        ms.pixelType = ifd.getPixelType();
        ms.metadataComplete = true;
        ms.interleaved = false;
        ms.falseColor = false;
        ms.dimensionOrder = "XYCZT";
        ms.thumbnail = s != 0;
    }
}
Also used : IFD(loci.formats.tiff.IFD) PhotoInterp(loci.formats.tiff.PhotoInterp) CoreMetadata(loci.formats.CoreMetadata)

Aggregations

IFD (loci.formats.tiff.IFD)121 TiffParser (loci.formats.tiff.TiffParser)74 RandomAccessInputStream (loci.common.RandomAccessInputStream)51 CoreMetadata (loci.formats.CoreMetadata)33 FormatException (loci.formats.FormatException)32 MetadataStore (loci.formats.meta.MetadataStore)21 IFDList (loci.formats.tiff.IFDList)21 PhotoInterp (loci.formats.tiff.PhotoInterp)18 IOException (java.io.IOException)17 Location (loci.common.Location)15 ArrayList (java.util.ArrayList)14 Timestamp (ome.xml.model.primitives.Timestamp)11 Length (ome.units.quantity.Length)10 Time (ome.units.quantity.Time)8 TiffIFDEntry (loci.formats.tiff.TiffIFDEntry)7 TiffRational (loci.formats.tiff.TiffRational)6 File (java.io.File)5 TiffReader (loci.formats.in.TiffReader)5 NonNegativeInteger (ome.xml.model.primitives.NonNegativeInteger)5 PositiveInteger (ome.xml.model.primitives.PositiveInteger)5