Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

16-bit images don't open #17

Open
K-Meech opened this issue Nov 23, 2021 · 3 comments
Open

16-bit images don't open #17

K-Meech opened this issue Nov 23, 2021 · 3 comments

Comments

@K-Meech
Copy link
Collaborator

K-Meech commented Nov 23, 2021

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

@tischi
Copy link
Collaborator

tischi commented Nov 23, 2021

in MoBIE I always do an on-the-fly conversion to 8-bit...

@K-Meech
Copy link
Collaborator Author

K-Meech commented Nov 23, 2021

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 :)

@tischi
Copy link
Collaborator

tischi commented Nov 23, 2021

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 :).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants