-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ExampleSourceAndConverter4D, lifted from #40
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ); | ||
} | ||
} |