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

2D support in TransformedBoxSelectionDialog #145

Open
karlduderstadt opened this issue Oct 14, 2022 · 1 comment
Open

2D support in TransformedBoxSelectionDialog #145

karlduderstadt opened this issue Oct 14, 2022 · 1 comment

Comments

@karlduderstadt
Copy link

The TransformedBoxSelectionDialog doesn't support 2D.

If TransformedBoxSelectionDialog is provided with 2D intervals an ArrayIndexOutOfBoundsException is thrown.
image

This can be reproduced in Fiji using the following groovy script:

import java.util.Random;
import bdv.util.*;

import net.imglib2.Interval;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.util.Intervals;
import net.imglib2.view.Views;

import bdv.tools.boundingbox.BoxSelectionOptions;
import bdv.tools.boundingbox.TransformedBoxSelectionDialog;

Random random = new Random();

Img< UnsignedByteType > img = ArrayImgs.unsignedBytes( 100, 100, 10 );
img.forEach( t -> t.set( random.nextInt( 128 ) ) );

AffineTransform3D imageTransform = new AffineTransform3D();
imageTransform.set( 2, 2, 2 );
def bdv = BdvFunctions.show( img, "image", BdvOptions.options().sourceTransform( imageTransform ).is2D() );

Interval initialInterval = Intervals.createMinMax( 30, 30, 80, 80 );
Interval rangeInterval = Intervals.createMinMax( 0, 0, 100, 100 );
TransformedBoxSelectionDialog.Result result = BdvFunctions.selectBox(
		bdv,
		imageTransform,
		initialInterval,
		rangeInterval,
		BoxSelectionOptions.options()
				.title( "Select box to fill" )
				.selectTimepointRange()
				.initialTimepointRange( 0, 5 ) );

if ( result.isValid() )
{
	for ( int tp = result.getMinTimepoint(); tp <= result.getMaxTimepoint(); ++tp )
		Views.interval( Views.extendZero( Views.hyperSlice( img, 3, tp ) ), result.getInterval() ).forEach( t -> t.set( 255 ) );
	bdv.getBdvHandle().getViewerPanel().requestRepaint();
}

However, it is possible to use the TransformedBoxSelectionDialog with the BDV in 2D mode as long as the intervals provided are 3D with the third dimension set to zero. The following groovy script works:

import java.util.Random;
import bdv.util.*;

import net.imglib2.Interval;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.realtransform.AffineTransform3D;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.util.Intervals;
import net.imglib2.view.Views;

import bdv.tools.boundingbox.BoxSelectionOptions;
import bdv.tools.boundingbox.TransformedBoxSelectionDialog;

Random random = new Random();

Img< UnsignedByteType > img = ArrayImgs.unsignedBytes( 100, 100, 10 );
img.forEach( t -> t.set( random.nextInt( 128 ) ) );

AffineTransform3D imageTransform = new AffineTransform3D();
imageTransform.set( 2, 2, 2 );
def bdv = BdvFunctions.show( img, "image", BdvOptions.options().sourceTransform( imageTransform ).is2D() );

final Interval initialInterval = Intervals.createMinMax( 0, 0, 0, 40, 40, 0 );
final Interval rangeInterval = Intervals.createMinMax( 0, 0, 0, 100, 100, 0 );
TransformedBoxSelectionDialog.Result result = BdvFunctions.selectBox(
		bdv,
		imageTransform,
		initialInterval,
		rangeInterval,
		BoxSelectionOptions.options()
				.title( "Select box to fill" )
				.selectTimepointRange()
				.initialTimepointRange( 0, 5 ) );

if ( result.isValid() )
{
	for ( int tp = result.getMinTimepoint(); tp <= result.getMaxTimepoint(); ++tp )
		Views.interval( Views.extendZero( Views.hyperSlice( img, 2, tp ) ), result.getInterval() ).forEach( t -> t.set( 255 ) );
	bdv.getBdvHandle().getViewerPanel().requestRepaint();
}

This is is a suitable workaround for the problem. However, the dialog then shows the z scrollbars and when zooming in closely both the green box on top and bottom below are visible. So a 3D box is kind of still drawn.

It would be nice if 2D intervals could be provided to the TransformedBoxSelectionDialog and the Dialog then showed up without the z scrollbars. It would also make sense to only show the green box in this situation and not have the background box outline. This part is more a minor comment. I think removing the z scrollbar would resolve the issue.

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/real-box-selection-dialogs-in-bigdataviewer/22650/9

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