Skip to content

Commit

Permalink
Add ExampleSourceAndConverter4D, lifted from #40
Browse files Browse the repository at this point in the history
  • Loading branch information
tpietzsch committed Jan 8, 2024
1 parent 3c0decf commit 2e0f139
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/test/java/bdv/util/ExampleSourceAndConverter4D.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package bdv.util;

import bdv.viewer.SourceAndConverter;
import net.imglib2.converter.Converter;
import net.imglib2.display.ColorConverter;
import net.imglib2.display.RealARGBColorConverter;
import net.imglib2.display.ScaledARGBConverter;
import net.imglib2.img.Img;
import net.imglib2.img.array.ArrayImg;
import net.imglib2.img.array.ArrayImgs;
import net.imglib2.img.basictypeaccess.array.IntArray;
import net.imglib2.type.numeric.ARGBType;
import net.imglib2.type.numeric.NumericType;
import net.imglib2.type.numeric.RealType;
import net.imglib2.type.numeric.integer.IntType;
import net.imglib2.util.Util;

import java.util.Random;

public class ExampleSourceAndConverter4D
{
public static void main( String[] args )
{
System.setProperty( "apple.laf.useScreenMenuBar", "true" );

final Random random = new Random();

final int numTimePoints = 5;
final Img< IntType > ints = ArrayImgs.ints( 100, 100, 100, numTimePoints );
ints.forEach( t -> t.set( random.nextInt( 65535 ) ) );

final IntType type = new IntType();
final RandomAccessibleIntervalSource4D< IntType > raiSource4D =
new RandomAccessibleIntervalSource4D<>( ints, type, "4d rai source" );
final RealARGBColorConverter< IntType > colorConverter =
RealARGBColorConverter.create( type, 0, 65535 );
final SourceAndConverter< IntType > sourceAndConverter =
new SourceAndConverter<>( raiSource4D, colorConverter );

BdvFunctions.show( sourceAndConverter, numTimePoints );
}
}

0 comments on commit 2e0f139

Please sign in to comment.