use of loci.common.RandomAccessInputStream in project bioformats by openmicroscopy.
the class NDPIReader method openBytes.
/**
* @see loci.formats.IFormatReader#openBytes(int, byte[], int, int, int, int)
*/
@Override
public byte[] openBytes(int no, byte[] buf, int x, int y, int w, int h) throws FormatException, IOException {
FormatTools.checkPlaneParameters(this, no, buf.length, x, y, w, h);
if (x == 0 && y == 0 && w == 1 && h == 1) {
return buf;
} else if (getSizeX() <= MAX_SIZE || getSizeY() <= MAX_SIZE) {
int ifdIndex = getIFDIndex(getCoreIndex(), no);
in = new RandomAccessInputStream(currentId);
tiffParser = new TiffParser(in);
tiffParser.setUse64BitOffsets(true);
tiffParser.setYCbCrCorrection(false);
byte[] b = tiffParser.getSamples(ifds.get(ifdIndex), buf, x, y, w, h);
in.close();
tiffParser.getStream().close();
return b;
}
if (initializedSeries != getCoreIndex() || initializedPlane != no) {
IFD ifd = ifds.get(getIFDIndex(getCoreIndex(), no));
long offset = ifd.getStripOffsets()[0];
long byteCount = ifd.getStripByteCounts()[0];
if (in != null) {
in.close();
}
in = new RandomAccessInputStream(currentId);
in.seek(offset);
in.setLength(offset + byteCount);
try {
service.close();
long[] markers = ifd.getIFDLongArray(MARKER_TAG);
if (!use64Bit) {
for (int i = 0; i < markers.length; i++) {
markers[i] = markers[i] & 0xffffffffL;
}
}
if (markers != null) {
service.setRestartMarkers(markers);
}
service.initialize(in, getSizeX(), getSizeY());
} catch (ServiceException e) {
throw new FormatException(e);
}
initializedSeries = getCoreIndex();
initializedPlane = no;
}
service.getTile(buf, x, y, w, h);
return buf;
}
use of loci.common.RandomAccessInputStream in project bioformats by openmicroscopy.
the class NDPIReader method initStandardMetadata.
// -- Internal BaseTiffReader API methods --
/* @see loci.formats.BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
super.initStandardMetadata();
ifds = tiffParser.getIFDs();
// fix the offsets for > 4 GB files
RandomAccessInputStream stream = new RandomAccessInputStream(currentId);
for (int i = 0; i < ifds.size(); i++) {
IFD ifd = ifds.get(i);
long[] stripOffsets = ifd.getStripOffsets();
boolean neededAdjustment = false;
for (int j = 0; j < stripOffsets.length; j++) {
long prevOffset = i == 0 ? 0 : ifds.get(i - 1).getStripOffsets()[0];
long prevByteCount = i == 0 ? 0 : ifds.get(i - 1).getStripByteCounts()[0];
long currentOffset = (int) stripOffsets[j];
while (currentOffset < prevOffset || currentOffset < prevOffset + prevByteCount) {
long newOffset = currentOffset + 0x100000000L;
if (newOffset < stream.length() && ((j > 0 && (currentOffset < stripOffsets[j - 1])) || (i > 0 && currentOffset < prevOffset + prevByteCount))) {
stripOffsets[j] = newOffset;
currentOffset = stripOffsets[j];
neededAdjustment = true;
}
}
}
if (neededAdjustment) {
ifd.putIFDValue(IFD.STRIP_OFFSETS, stripOffsets);
}
neededAdjustment = false;
long[] stripByteCounts = ifd.getStripByteCounts();
for (int j = 0; j < stripByteCounts.length; j++) {
long currentCount = (int) stripByteCounts[j];
long newByteCount = currentCount + 0x100000000L;
if (currentCount < 0 || neededAdjustment || newByteCount + stripOffsets[j] < in.length()) {
if (newByteCount < ifd.getImageWidth() * ifd.getImageLength()) {
stripByteCounts[j] = newByteCount;
neededAdjustment = true;
}
}
}
if (neededAdjustment) {
ifd.putIFDValue(IFD.STRIP_BYTE_COUNTS, stripByteCounts);
}
}
stream.close();
for (int i = 1; i < ifds.size(); i++) {
IFD ifd = ifds.get(i);
if (ifd.getImageWidth() == ifds.get(0).getImageWidth() && ifd.getImageLength() == ifds.get(0).getImageLength()) {
sizeZ++;
} else if (sizeZ == 1) {
boolean isPyramid;
Object source_lens_value = ifd.getIFDValue(SOURCE_LENS);
if (source_lens_value != null) {
float source_lens = (Float) source_lens_value;
// A value of -1 correspond to the macro image and a value of -2
// correspond to the map image
isPyramid = (source_lens != -1 && source_lens != -2);
} else {
// Assume the last IFD is the macro image
isPyramid = i < ifds.size() - 1;
}
if (isPyramid)
pyramidHeight++;
}
}
// repopulate core metadata
int seriesCount = pyramidHeight + (ifds.size() - pyramidHeight * sizeZ);
for (int i = 0; i < ifds.size(); i++) {
IFD ifd = ifds.get(i);
ifd.remove(THUMB_TAG_2);
ifds.set(i, ifd);
TiffIFDEntry markerTag = (TiffIFDEntry) ifd.get(MARKER_TAG);
if (markerTag != null) {
if (markerTag.getValueOffset() > in.length()) {
// can't rely upon the MARKER_TAG to be detected correctly
ifds.get(i).remove(MARKER_TAG);
} else {
Object value = tiffParser.getIFDValue(markerTag);
ifds.get(i).putIFDValue(MARKER_TAG, value);
}
}
tiffParser.fillInIFD(ifds.get(i));
int[] bpp = ifds.get(i).getBitsPerSample();
for (int q = 0; q < bpp.length; q++) {
if (bpp[q] < 8) {
bpp[q] = 8;
}
}
ifds.get(i).putIFDValue(IFD.BITS_PER_SAMPLE, bpp);
}
core.clear();
for (int s = 0; s < seriesCount; s++) {
CoreMetadata ms = new CoreMetadata();
core.add(ms);
if (s == 0) {
ms.resolutionCount = pyramidHeight;
}
}
for (int s = 0; s < core.size(); s++) {
IFD ifd = ifds.get(getIFDIndex(s, 0));
PhotoInterp p = ifd.getPhotometricInterpretation();
int samples = ifd.getSamplesPerPixel();
CoreMetadata ms = core.get(s);
ms.rgb = samples > 1 || p == PhotoInterp.RGB;
ms.sizeX = (int) ifd.getImageWidth();
ms.sizeY = (int) ifd.getImageLength();
ms.sizeZ = s < pyramidHeight ? 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 = ms.sizeZ * ms.sizeT;
ms.pixelType = ifd.getPixelType();
ms.metadataComplete = true;
ms.interleaved = ms.sizeX > MAX_SIZE && ms.sizeY > MAX_SIZE;
ms.falseColor = false;
ms.dimensionOrder = "XYCZT";
ms.thumbnail = s != 0;
}
String metadataTag = ifds.get(0).getIFDStringValue(METADATA_TAG);
if (metadataTag != null) {
String[] entries = metadataTag.split("\n");
for (String entry : entries) {
int eq = entry.indexOf('=');
if (eq < 0) {
continue;
}
String key = entry.substring(0, eq).trim();
String value = entry.substring(eq + 1).trim();
addGlobalMeta(key, value);
if (key.equals("Objective.Lens.Magnificant")) {
// not a typo
magnification = new Double(value);
} else if (key.equals("NDP.S/N")) {
serialNumber = value;
} else if (key.equals("Product")) {
instrumentModel = value;
}
}
}
}
use of loci.common.RandomAccessInputStream in project bioformats by openmicroscopy.
the class NikonReader method initStandardMetadata.
// -- Internal BaseTiffReader API methods --
/* @see BaseTiffReader#initStandardMetadata() */
@Override
protected void initStandardMetadata() throws FormatException, IOException {
super.initStandardMetadata();
// reset image dimensions
// the actual image data is stored in IFDs referenced by the SubIFD tag
// in the 'real' IFD
CoreMetadata m = core.get(0);
m.imageCount = ifds.size();
IFD firstIFD = ifds.get(0);
PhotoInterp photo = firstIFD.getPhotometricInterpretation();
int samples = firstIFD.getSamplesPerPixel();
m.rgb = samples > 1 || photo == PhotoInterp.RGB || photo == PhotoInterp.CFA_ARRAY;
if (photo == PhotoInterp.CFA_ARRAY)
samples = 3;
m.sizeX = (int) firstIFD.getImageWidth();
m.sizeY = (int) firstIFD.getImageLength();
m.sizeZ = 1;
m.sizeC = isRGB() ? samples : 1;
m.sizeT = ifds.size();
m.pixelType = firstIFD.getPixelType();
m.indexed = false;
// now look for the EXIF IFD pointer
IFDList exifIFDs = tiffParser.getExifIFDs();
if (exifIFDs.size() > 0) {
IFD exifIFD = exifIFDs.get(0);
tiffParser.fillInIFD(exifIFD);
for (Integer key : exifIFD.keySet()) {
int tag = key.intValue();
String name = IFD.getIFDTagName(tag);
if (tag == IFD.CFA_PATTERN) {
byte[] cfa = (byte[]) exifIFD.get(key);
int[] colorMap = new int[cfa.length];
for (int i = 0; i < cfa.length; i++) colorMap[i] = (int) cfa[i];
addGlobalMeta(name, colorMap);
cfaPattern = colorMap;
} else {
addGlobalMeta(name, exifIFD.get(key));
if (name.equals("MAKER_NOTE")) {
byte[] b = (byte[]) exifIFD.get(key);
int extra = new String(b, 0, 10, Constants.ENCODING).startsWith("Nikon") ? 10 : 0;
byte[] buf = new byte[b.length];
System.arraycopy(b, extra, buf, 0, buf.length - extra);
RandomAccessInputStream makerNote = new RandomAccessInputStream(buf);
TiffParser tp = new TiffParser(makerNote);
IFD note = null;
try {
note = tp.getFirstIFD();
} catch (Exception e) {
LOGGER.debug("Failed to parse first IFD", e);
}
if (note != null) {
for (Integer nextKey : note.keySet()) {
int nextTag = nextKey.intValue();
addGlobalMeta(name, note.get(nextKey));
if (nextTag == 150) {
b = (byte[]) note.get(nextKey);
RandomAccessInputStream s = new RandomAccessInputStream(b);
byte check1 = s.readByte();
byte check2 = s.readByte();
lossyCompression = check1 != 0x46;
vPredictor = new int[4];
for (int q = 0; q < vPredictor.length; q++) {
vPredictor[q] = s.readShort();
}
curve = new int[16385];
int bps = ifds.get(0).getBitsPerSample()[0];
int max = 1 << bps & 0x7fff;
int step = 0;
int csize = s.readShort();
if (csize > 1) {
step = max / (csize - 1);
}
if (check1 == 0x44 && check2 == 0x20 && step > 0) {
for (int i = 0; i < csize; i++) {
curve[i * step] = s.readShort();
}
for (int i = 0; i < max; i++) {
int n = i % step;
curve[i] = (curve[i - n] * (step - n) + curve[i - n + step] * n) / step;
}
s.seek(562);
split = s.readShort();
} else {
int maxValue = (int) Math.pow(2, bps) - 1;
Arrays.fill(curve, maxValue);
int nElements = (int) (s.length() - s.getFilePointer()) / 2;
if (nElements < 100) {
for (int i = 0; i < curve.length; i++) {
curve[i] = (short) i;
}
} else {
for (int q = 0; q < nElements; q++) {
curve[q] = s.readShort();
}
}
}
s.close();
} else if (nextTag == WHITE_BALANCE_RGB_COEFFS) {
whiteBalance = (TiffRational[]) note.get(nextKey);
}
}
}
makerNote.close();
}
}
}
}
}
use of loci.common.RandomAccessInputStream in project bioformats by openmicroscopy.
the class OIRReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
Location current = new Location(id).getAbsoluteFile();
Location parent = current.getParentFile();
ArrayList<String> extraFiles = new ArrayList<String>();
if (parent != null) {
String[] fileList = parent.list();
Arrays.sort(fileList);
String prefix = current.getName();
if (prefix.indexOf(".") > 0) {
prefix = prefix.substring(0, prefix.lastIndexOf("."));
} else if (!checkSuffix(id, "oir")) {
prefix = prefix.substring(0, prefix.lastIndexOf("_"));
}
for (String file : fileList) {
// look for files ending with an underscore plus a 5 digit number
if (file.startsWith(prefix + "_") && file.length() == prefix.length() + 6) {
try {
int index = Integer.parseInt(file.substring(file.lastIndexOf("_") + 1));
if (index != extraFiles.size() + 1) {
LOGGER.warn("Found file {} with index {}; expected index {}", file, index, extraFiles.size() + 1);
}
extraFiles.add(new Location(parent, file).getAbsolutePath());
} catch (NumberFormatException e) {
}
} else if (file.startsWith(prefix) && checkSuffix(file, "oir")) {
current = new Location(parent, file);
currentId = current.getAbsolutePath();
}
}
}
CoreMetadata m = core.get(0);
m.littleEndian = true;
m.sizeZ = 1;
m.sizeC = 1;
m.sizeT = 1;
m.indexed = true;
m.falseColor = true;
try (RandomAccessInputStream s = new RandomAccessInputStream(currentId, BUFFER_SIZE)) {
readPixelsFile(current.getAbsolutePath(), s);
}
for (String file : extraFiles) {
try (RandomAccessInputStream s = new RandomAccessInputStream(file, BUFFER_SIZE)) {
readPixelsFile(file, s);
}
}
m.sizeC *= channels.size();
m.imageCount = getSizeC() * getSizeZ() * getSizeT();
LOGGER.debug("blocks per plane = {}", blocksPerPlane);
LOGGER.debug("number of pixel blocks = {}", pixelBlocks.size());
if (blocksPerPlane * getImageCount() != pixelBlocks.size()) {
// if blocks are missing, set the Z and T dimensions to match the last
// plane for which at least one block exists
int maxZ = 0;
int maxT = 0;
for (String uid : pixelBlocks.keySet()) {
LOGGER.debug(" checking uid = {}", uid);
int thisZ = getZ(uid);
int thisT = getT(uid);
int block = getBlock(uid);
// only count through last full plane
if (block == blocksPerPlane - 1) {
if (thisZ > maxZ) {
maxZ = thisZ;
}
if (thisT > maxT) {
maxT = thisT;
}
if (thisZ < minZ) {
minZ = thisZ;
}
if (thisT < minT) {
minT = thisT;
}
}
}
m.sizeZ = (maxZ - minZ) + 1;
m.sizeT = (maxT - minT) + 1;
m.imageCount = getSizeC() * getSizeZ() * getSizeT();
} else {
minZ = 0;
minT = 0;
}
m.dimensionOrder = "XYC";
if (getSizeZ() == 1 || getSizeT() == 1) {
m.dimensionOrder += "ZT";
} else {
int zIndex = baseName.toLowerCase().indexOf("z");
int tIndex = baseName.toLowerCase().indexOf("t");
if (zIndex < tIndex) {
m.dimensionOrder += "TZ";
} else {
m.dimensionOrder += "ZT";
}
}
pixelUIDs = pixelBlocks.keySet().toArray(new String[pixelBlocks.size()]);
Arrays.sort(pixelUIDs, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
int lastUnderscore1 = s1.lastIndexOf("_");
int lastUnderscore2 = s2.lastIndexOf("_");
Integer block1 = new Integer(s1.substring(lastUnderscore1 + 1));
Integer block2 = new Integer(s2.substring(lastUnderscore2 + 1));
int underscore1 = s1.lastIndexOf("_", lastUnderscore1 - 1);
int underscore2 = s2.lastIndexOf("_", lastUnderscore2 - 1);
String prefix1 = s1.substring(0, underscore1);
String prefix2 = s2.substring(0, underscore2);
String channel1 = s1.substring(underscore1 + 1, lastUnderscore1);
String channel2 = s2.substring(underscore2 + 1, lastUnderscore2);
if (!prefix1.equals(prefix2)) {
return s1.compareTo(s2);
}
if (!channel1.equals(channel2)) {
Integer index1 = -1;
Integer index2 = -2;
for (int i = 0; i < channels.size(); i++) {
if (channels.get(i).id.equals(channel1)) {
index1 = i;
}
if (channels.get(i).id.equals(channel2)) {
index2 = i;
}
}
return index1.compareTo(index2);
}
return block1.compareTo(block2);
}
});
if (LOGGER.isTraceEnabled()) {
for (int i = 0; i < pixelUIDs.length; i++) {
LOGGER.trace("pixel UID #{} = {}", i, pixelUIDs[i]);
}
}
// populate original metadata
Hashtable<String, Object> tmpMeta = new Hashtable<String, Object>();
addMeta("Creation date", acquisitionDate, tmpMeta);
addMeta("Pixel Length X", physicalSizeX, tmpMeta);
addMeta("Pixel Length Y", physicalSizeY, tmpMeta);
addMeta("Z step", physicalSizeZ, tmpMeta);
for (Channel channel : channels) {
String prefix = "Channel " + channel.name + " ";
addMetaList(prefix + "ID", channel.id, tmpMeta);
addMetaList(prefix + "color", channel.color, tmpMeta);
addMetaList(prefix + "pinhole", channel.pinhole, tmpMeta);
addMetaList(prefix + "start wavelength", channel.excitation, tmpMeta);
addMetaList(prefix + "end wavelength", channel.emission, tmpMeta);
addMetaList(prefix + "linked laser index", channel.laserIndex, tmpMeta);
}
for (Objective objective : objectives) {
addMetaList("Objective Lens name", objective.name, tmpMeta);
addMetaList("Objective Lens magnification", objective.magnification, tmpMeta);
addMetaList("Objective Lens na", objective.na, tmpMeta);
addMetaList("Objective Lens wd", objective.wd, tmpMeta);
addMetaList("Objective Lens refractive index", objective.ri, tmpMeta);
addMetaList("Objective Lens immersion", objective.immersion, tmpMeta);
}
for (Laser laser : lasers) {
String prefix = "Laser " + laser.name + " ";
addMetaList(prefix + "ID", laser.id, tmpMeta);
addMetaList(prefix + "data ID", laser.dataId, tmpMeta);
addMetaList(prefix + "power", laser.power, tmpMeta);
addMetaList(prefix + "transmissivity", laser.transmissivity, tmpMeta);
addMetaList(prefix + "wavelength", laser.wavelength, tmpMeta);
}
for (Detector detector : detectors) {
addMetaList("Detector ID", detector.id, tmpMeta);
addMetaList("Detector linked channel ID", detector.channelId, tmpMeta);
addMetaList("Detector voltage", detector.voltage, tmpMeta);
addMetaList("Detector offset", detector.offset, tmpMeta);
addMetaList("Detector gain", detector.gain, tmpMeta);
}
// this ensures that global metadata keys will be sorted before series keys
MetadataTools.merge(tmpMeta, metadata, "- ");
// populate MetadataStore
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
String instrumentID = MetadataTools.createLSID("Instrument", 0);
store.setInstrumentID(instrumentID, 0);
store.setImageInstrumentRef(instrumentID, 0);
for (int i = 0; i < lasers.size(); i++) {
Laser l = lasers.get(i);
String lsid = MetadataTools.createLSID("LightSource", 0, i);
store.setLaserID(lsid, 0, i);
store.setLaserModel(l.id, 0, i);
if (l.wavelength != null) {
store.setLaserWavelength(FormatTools.getWavelength(l.wavelength, null), 0, i);
}
}
for (int i = 0; i < detectors.size(); i++) {
Detector detector = detectors.get(i);
String lsid = MetadataTools.createLSID("Detector", 0, i);
store.setDetectorID(lsid, 0, i);
store.setDetectorOffset(detector.offset, 0, i);
store.setDetectorVoltage(FormatTools.createElectricPotential(detector.voltage, UNITS.VOLT), 0, i);
store.setDetectorGain(detector.gain, 0, i);
}
for (int i = 0; i < objectives.size(); i++) {
Objective objective = objectives.get(i);
String lsid = MetadataTools.createLSID("Objective", 0, i);
store.setObjectiveID(lsid, 0, i);
store.setObjectiveModel(objective.name, 0, i);
store.setObjectiveNominalMagnification(objective.magnification, 0, i);
store.setObjectiveLensNA(objective.na, 0, i);
store.setObjectiveWorkingDistance(FormatTools.createLength(objective.wd, UNITS.MILLIMETRE), 0, i);
store.setObjectiveImmersion(objective.immersion, 0, i);
if (i == 0) {
store.setObjectiveSettingsID(lsid, 0);
store.setObjectiveSettingsRefractiveIndex(objective.ri, 0);
}
}
if (acquisitionDate != null) {
store.setImageAcquisitionDate(acquisitionDate, 0);
}
if (physicalSizeX != null) {
store.setPixelsPhysicalSizeX(physicalSizeX, 0);
}
if (physicalSizeY != null) {
store.setPixelsPhysicalSizeY(physicalSizeY, 0);
}
if (physicalSizeZ != null) {
store.setPixelsPhysicalSizeZ(physicalSizeZ, 0);
}
for (int c = 0; c < channels.size(); c++) {
Channel ch = channels.get(c);
store.setChannelName(ch.name, 0, c);
if (ch.color != null) {
store.setChannelColor(ch.color, 0, c);
}
if (ch.pinhole != null) {
store.setChannelPinholeSize(ch.pinhole, 0, c);
}
if (ch.emission != null) {
store.setChannelEmissionWavelength(ch.emission, 0, c);
}
if (ch.excitation != null) {
store.setChannelExcitationWavelength(ch.excitation, 0, c);
}
for (int d = 0; d < detectors.size(); d++) {
if (detectors.get(d).channelId.equals(ch.id)) {
store.setDetectorSettingsID(MetadataTools.createLSID("Detector", 0, d), 0, c);
}
}
if (ch.laserIndex >= 0 && ch.laserIndex < lasers.size()) {
String laserId = MetadataTools.createLSID("LightSource", 0, ch.laserIndex);
store.setChannelLightSourceSettingsID(laserId, 0, c);
}
}
}
use of loci.common.RandomAccessInputStream in project bioformats by openmicroscopy.
the class OpenlabRawReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
in = new RandomAccessInputStream(id);
// read the 12 byte file header
LOGGER.info("Verifying Openlab RAW format");
if (!in.readString(4).equals("OLRW")) {
throw new FormatException("Openlab RAW magic string not found.");
}
LOGGER.info("Populating metadata");
CoreMetadata m = core.get(0);
int version = in.readInt();
m.imageCount = in.readInt();
offsets = new int[getImageCount()];
offsets[0] = 12;
in.skipBytes(8);
m.sizeX = in.readInt();
m.sizeY = in.readInt();
in.skipBytes(1);
m.sizeC = in.read();
bytesPerPixel = in.read();
in.skipBytes(1);
long stampMs = in.readLong();
if (stampMs > 0) {
stampMs /= 1000000;
stampMs -= (67 * 365.25 * 24 * 60 * 60);
} else
stampMs = System.currentTimeMillis();
String stamp = DateTools.convertDate(stampMs, DateTools.UNIX);
in.skipBytes(4);
int len = in.read() & 0xff;
String imageName = in.readString(len - 1).trim();
if (getSizeC() <= 1)
m.sizeC = 1;
else
m.sizeC = 3;
int plane = getSizeX() * getSizeY() * bytesPerPixel;
for (int i = 1; i < getImageCount(); i++) {
offsets[i] = offsets[i - 1] + HEADER_SIZE + plane;
}
m.sizeZ = getImageCount();
m.sizeT = 1;
m.rgb = getSizeC() > 1;
m.dimensionOrder = isRGB() ? "XYCZT" : "XYZTC";
m.interleaved = false;
m.littleEndian = false;
m.metadataComplete = true;
m.indexed = false;
m.falseColor = false;
switch(bytesPerPixel) {
case 1:
case 3:
m.pixelType = FormatTools.UINT8;
break;
case 2:
m.pixelType = FormatTools.UINT16;
break;
default:
m.pixelType = FormatTools.FLOAT;
}
addGlobalMeta("Width", getSizeX());
addGlobalMeta("Height", getSizeY());
addGlobalMeta("Bytes per pixel", bytesPerPixel);
addGlobalMeta("Image name", imageName);
addGlobalMeta("Timestamp", stamp);
addGlobalMeta("Version", version);
// The metadata store we're working with.
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
if (stamp != null) {
store.setImageAcquisitionDate(new Timestamp(stamp), 0);
}
store.setImageName(imageName, 0);
}
Aggregations