Map<URI, ImageFileDetails> imageFiles = new HashMap<URI, ImageFileDetails>();
Map<URI, Map<Integer, ImageSeriesDetails>> imageSeries = new HashMap<URI, Map<Integer,ImageSeriesDetails>>();
final Pixels pixels = omeImage.getPixels();
int [] coords = new int[numDimensions()];
for (int planeIdx=0; planeIdx<pixels.sizeOfPlaneList() && planeIdx<pixels.sizeOfTiffDataList(); planeIdx++) {
final Plane plane = pixels.getPlane(planeIdx);
final TiffData location = pixels.getTiffData(planeIdx);
final URI uri = new URI(location.getUUID().getFileName());
if (! imageFiles.containsKey(uri)) {
imageFiles.put(uri, new ImageFileDetails(new ImageFile(uri)));
}
final ImageFileDetails ifd = imageFiles.get(uri);
final int series = getLongAnnotationFromPlane(plane, SERIES_ANNOTATION_DESCRIPTION, 0);
if (! imageSeries.containsKey(uri)) {
imageSeries.put(uri, new HashMap<Integer, ImageSeriesDetails>());
}
Map<Integer, ImageSeriesDetails> idx2Series = imageSeries.get(uri);
if (! idx2Series.containsKey(series)) {
idx2Series.put(series, new ImageSeriesDetails(new ImageSeries(ifd.getImageFile(), series), ifd));
}
final ImageSeriesDetails isd = idx2Series.get(series);
final int idx = location.getIFD().getValue();
final int channel = getLongAnnotationFromPlane(plane, CHANNEL_ANNOTATION_DESCRIPTION, ImagePlane.ALWAYS_MONOCHROME);
final ImagePlane imagePlane = new ImagePlane(isd.getImageSeries(), idx, channel);
final ImagePlaneDetails ipd = new ImagePlaneDetails(imagePlane, isd);
for (int didx=0; didx<numDimensions();didx++) {
AxisType at = axis(didx).type();
if (at.equals(Axes.CHANNEL)) {
coords[didx] = plane.getTheC().getValue();
} else if (at.equals(Axes.Z)) {
coords[didx] = plane.getTheZ().getValue();
} else if (at.equals(Axes.TIME)) {
coords[didx] = plane.getTheT().getValue();
} else if (at.equals(OBJECT_PLANE_AXIS_TYPE)) {
coords[didx] = planeIdx;
}
}
add(ipd, coords);