Skip to content

Instantly share code, notes, and snippets.

@hkmoon
Created August 9, 2017 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hkmoon/79c17d8a3132e7f646e500d167c53b14 to your computer and use it in GitHub Desktop.
Save hkmoon/79c17d8a3132e7f646e500d167c53b14 to your computer and use it in GitHub Desktop.
ROI in HDF4ImageLoader
void process(File hdf5, SpimDataMinimal spimData, Interval roi) {
AbstractSequenceDescription<?, ?, ?> sequenceDescription = spimData.getSequenceDescription();
Hdf5ImageLoader hdf5Loader = new Hdf5ImageLoader(hdf5, /* hdf5 partitions */ null, sequenceDescription);
for (TimePoint timepoint : sequenceDescription.getTimePoints().getTimePointsOrdered()) {
for (BasicViewSetup setup : sequenceDescription.getViewSetupsOrdered()) {
RandomAccessibleInterval<UnsignedShortType> img = hdf5Loader.getSetupImgLoader(setup.getId()).getImage(timepoint.getId(), 0); // full res
RandomAccessibleInterval<UnsignedShortType> imgRoi = Views.interval(img, roi);
// process imgRoi here, it will be lazily loaded when accessed
}
}
}
final BasicMultiResolutionSetupImgLoader< ? > loader = ( ( BasicMultiResolutionImgLoader ) seq.getImgLoader() ).getSetupImgLoader( setup );
final RandomAccessibleInterval< ? > img = loader.getImage( timepoint, level, ImgLoaderHints.LOAD_COMPLETELY );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment