Open K-Meech opened 2 years ago
in MoBIE I always do an on-the-fly conversion to 8-bit...
Good point - that is probably a better way to go! Could you link me to where you do this in MoBIE? Then I'll steal it :)
It is in the ImageVolumeViewer
class:
private static < R extends RealType< R > & NativeType< R > > ImagePlus createUnsignedByteImagePlus( Source< ? > source, int min, int max, Integer level )
{
RandomAccessibleInterval< R > rai = ( RandomAccessibleInterval ) source.getSource( 0, level );
rai = CopyUtils.copyVolumeRaiMultiThreaded( rai, Prefs.getThreads() - 1 ); // TODO: make multi-threading configurable.
rai = Views.permute( Views.addDimension( rai, 0, 0 ), 2, 3 );
final ImagePlus wrap = ImageJFunctions.wrapUnsignedByte(
rai,
new RealUnsignedByteConverter< R >( min, max ),
source.getName() );
final double[] voxelSpacing = getVoxelSpacings( source ).get( level );
wrap.getCalibration().pixelWidth = voxelSpacing[ 0 ];
wrap.getCalibration().pixelHeight = voxelSpacing[ 1 ];
wrap.getCalibration().pixelDepth = voxelSpacing[ 2 ];
return wrap;
}
the min
and max
are the contrast limits, which are currently determined like this:
private int[] getContrastLimits( SourceAndConverter< ? > sac )
{
final Object type = Util.getTypeFromInterval( sac.getSpimSource().getSource( 0, 0 ) );
final int[] contrastLimits = new int[ 2 ];
contrastLimits[ 0 ] = 0;
if ( type instanceof UnsignedByteType )
contrastLimits[ 1 ] = 255;
else if ( type instanceof UnsignedShortType )
contrastLimits[ 1 ] = 65535;
else
throw new RuntimeException( "Volume view of image of type " + type + " is currently not supported.");
return contrastLimits;
}
Do you depend on mobie? If yes, you can also refactor those methods to make them public static
and then use them (I'd accept a PR :).
I think this is a hard limitation of the imageJ 3D viewer, so we should probably just warn in the docs that you need 8-bit