Search in sources :

Example 1 with N5ImagePlusMetadata

use of org.janelia.saalfeldlab.n5.metadata.imagej.N5ImagePlusMetadata in project bigwarp by saalfeldlab.

the class BigWarpInit method openAsSource.

@SuppressWarnings({ "unchecked", "rawtypes" })
public static <T extends N5Metadata> Source<?> openAsSource(final N5Reader n5, final T meta, final boolean isVolatile) {
    final RandomAccessibleInterval imageRaw;
    final RandomAccessibleInterval image;
    try {
        if (isVolatile)
            imageRaw = to3d(N5Utils.openVolatile(n5, meta.getPath()));
        else
            imageRaw = to3d(N5Utils.open(n5, meta.getPath()));
        if (meta instanceof N5ImagePlusMetadata && ((N5ImagePlusMetadata) meta).getType() == ImagePlus.COLOR_RGB && Util.getTypeFromInterval(imageRaw) instanceof UnsignedIntType) {
            image = toColor(imageRaw);
        } else
            image = imageRaw;
        if (meta instanceof SpatialMetadata) {
            final String unit = ((SpatialMetadata) meta).unit();
            final AffineTransform3D srcXfm = ((SpatialMetadata) meta).spatialTransform3d();
            final FinalVoxelDimensions voxelDims = new FinalVoxelDimensions(unit, new double[] { srcXfm.get(0, 0), srcXfm.get(1, 1), srcXfm.get(2, 2) });
            return new BwRandomAccessibleIntervalSource(image, Util.getTypeFromInterval(image), srcXfm, meta.getPath(), voxelDims);
        } else
            return new BwRandomAccessibleIntervalSource(image, Util.getTypeFromInterval(image), new AffineTransform3D(), meta.getPath());
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : N5ImagePlusMetadata(org.janelia.saalfeldlab.n5.metadata.imagej.N5ImagePlusMetadata) RandomAccessibleInterval(net.imglib2.RandomAccessibleInterval) SpatialMetadata(org.janelia.saalfeldlab.n5.metadata.SpatialMetadata) FinalVoxelDimensions(mpicbg.spim.data.sequence.FinalVoxelDimensions) BwRandomAccessibleIntervalSource(bdv.img.BwRandomAccessibleIntervalSource) UnsignedIntType(net.imglib2.type.numeric.integer.UnsignedIntType) IOException(java.io.IOException) AffineTransform3D(net.imglib2.realtransform.AffineTransform3D)

Aggregations

BwRandomAccessibleIntervalSource (bdv.img.BwRandomAccessibleIntervalSource)1 IOException (java.io.IOException)1 FinalVoxelDimensions (mpicbg.spim.data.sequence.FinalVoxelDimensions)1 RandomAccessibleInterval (net.imglib2.RandomAccessibleInterval)1 AffineTransform3D (net.imglib2.realtransform.AffineTransform3D)1 UnsignedIntType (net.imglib2.type.numeric.integer.UnsignedIntType)1 SpatialMetadata (org.janelia.saalfeldlab.n5.metadata.SpatialMetadata)1 N5ImagePlusMetadata (org.janelia.saalfeldlab.n5.metadata.imagej.N5ImagePlusMetadata)1