Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/main/java/bvv/core/blocks/ByteUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,11 @@ public static void setBytes( final byte src, final long dst, final long csx )
UNSAFE.setMemory( dst, csx, src );
}

public interface Address
public static void copyBytes( final byte[] src, final long dst, final long sox, final long csx) {
UNSAFE.copyMemory( src, BYTE_ARRAY_OFFSET + sox, null, dst, csx );
}

public interface Address
{
long getAddress();
}
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/bvv/core/blocks/CopySubArrayImp.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ public void copysubarray3d( final short[] src, final int sox, final int soy, fin
}
}

public static class ByteToAddress implements CopySubArray< byte[], ByteUtils.Address >
{
@Override
public void clearsubarray3d( final ByteUtils.Address dst, final int dox, final int doy, final int doz, final int dsx, final int dsy, final int csx, final int csy, final int csz )
{
final ArrayFill fill = ( o, l ) -> ByteUtils.setBytes( ( byte ) 0, dst.getAddress() + o, l );
fillsubarray3dn( fill, dox, doy, doz, dsx, dsy, csx, csy, csz );
}

@Override
public void copysubarray3d( final byte[] src, final int sox, final int soy, final int soz, final int ssx, final int ssy, final ByteUtils.Address dst, final int dox, final int doy, final int doz, final int dsx, final int dsy, final int csx, final int csy, final int csz )
{
final ArrayCopy copy = ( so, o, l ) -> ByteUtils.copyBytes( src, dst.getAddress() + o, so, l );
copysubarray3dn( copy, sox, soy, soz, ssx, ssy, dox, doy, doz, dsx, dsy, csx, csy, csz );
}
}

static void copysubarray3dn(
ArrayCopy copysubarray1dn,
final int sox,
Expand Down
13 changes: 12 additions & 1 deletion src/main/java/bvv/core/blocks/TileAccess.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import net.imglib2.type.PrimitiveType;
import net.imglib2.util.Fraction;

import static net.imglib2.type.PrimitiveType.BYTE;
import static net.imglib2.type.PrimitiveType.SHORT;

/**
Expand Down Expand Up @@ -124,6 +125,16 @@ public boolean loadTile( final int[] gridPos, final UploadBuffer buffer )
new CopySubArrayImp.ShortToAddress(),
cacheSpec
);
} else if ( cacheSpec.format() == Texture.InternalFormat.R8 && cellimg )
{
final boolean volatil = type instanceof Volatile;
return new TileAccess<>(
volatil
? new GridDataAccessImp.VolatileCells<>( ( AbstractCellImg ) img )
: new GridDataAccessImp.Cells<>( ( AbstractCellImg ) img ),
new CopySubArrayImp.ByteToAddress(),
cacheSpec
);
}
}

Expand All @@ -137,7 +148,7 @@ public static boolean isSupportedType( final Object type )
{
final PrimitiveType primitive = ( ( NativeType ) type ).getNativeTypeFactory().getPrimitiveType();
final Fraction epp = ( ( NativeType ) type ).getEntitiesPerPixel();
if ( primitive == SHORT && epp.getNumerator() == epp.getDenominator() )
if (( primitive == SHORT && epp.getNumerator() == epp.getDenominator() )|| (primitive == BYTE && epp.getNumerator() == epp.getDenominator()))
return true;
}

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/bvv/core/render/VolumeRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/
package bvv.core.render;

import static bvv.core.backend.Texture.InternalFormat.R8;
import static com.jogamp.opengl.GL.GL_ALWAYS;
import static com.jogamp.opengl.GL.GL_BLEND;
import static com.jogamp.opengl.GL.GL_DEPTH_TEST;
Expand Down Expand Up @@ -62,6 +63,8 @@
import net.imglib2.type.numeric.ARGBType;
import net.imglib2.type.numeric.integer.UnsignedByteType;
import net.imglib2.type.numeric.integer.UnsignedShortType;
import net.imglib2.type.volatiles.VolatileUnsignedByteType;
import net.imglib2.type.volatiles.VolatileUnsignedShortType;
import org.joml.Matrix4f;

import bdv.tools.brightness.ConverterSetup;
Expand Down Expand Up @@ -177,7 +180,7 @@ public VolumeRenderer(

// set up gpu cache
// TODO This could be packaged into one class and potentially shared between renderers?
cacheSpec = new CacheSpec( R16, cacheBlockSize );
cacheSpec = new CacheSpec( R8, cacheBlockSize ); //new CacheSpec( R8, cacheBlockSize );
final int[] cacheGridDimensions = TextureCache.findSuitableGridSize( cacheSpec, maxCacheSizeInMB );
textureCache = new TextureCache( cacheGridDimensions, cacheSpec );
pboChain = new PboChain( 5, 100, textureCache );
Expand Down Expand Up @@ -276,7 +279,13 @@ else if ( type == LOAD )
if ( !TileAccess.isSupportedType( stack.getType() ) )
throw new IllegalArgumentException();
multiResStacks.add( ( MultiResolutionStack3D< ? > ) stack );
volumeSignatures.add( new VolumeSignature( MULTIRESOLUTION, USHORT ) );
final Object pixelType = stack.getType();
if (( pixelType instanceof UnsignedShortType ) || (pixelType instanceof VolatileUnsignedShortType))
volumeSignatures.add( new VolumeSignature( MULTIRESOLUTION, USHORT ) );
else if (( pixelType instanceof UnsignedByteType ) || (pixelType instanceof VolatileUnsignedByteType))
volumeSignatures.add( new VolumeSignature( MULTIRESOLUTION, UBYTE ) );
else
throw new IllegalArgumentException("Multiresolution stack with pixel type "+pixelType.getClass().getName()+" unsupported in BigVolumeViewer.");
}
else if ( stack instanceof SimpleStack3D )
{
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example01.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Example01
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/t1-head.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/t1-head.zip" );
final Img< UnsignedShortType > img = ImageJFunctions.wrapShort( imp );

final BvvSource source = BvvFunctions.show( img, "t1-head" );
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example02.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class Example02
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/flybrain.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/flybrain.zip" );
final Img< ARGBType > img = ImageJFunctions.wrapRGBA( imp );

// additional Bvv.options() to specify calibration
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example03.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class Example03
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/Spindly-GFP.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/Spindly-GFP.zip" );
final Img< UnsignedShortType > img = ImageJFunctions.wrapShort( imp );

final double pw = imp.getCalibration().pixelWidth;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example04.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class Example04
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/t1-head.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/t1-head.zip" );
final Img< UnsignedShortType > img = ImageJFunctions.wrapShort( imp );

final BvvSource source1 = BvvFunctions.show( img, "t1-head" );
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example06.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public class Example06
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/flybrain.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/flybrain.zip" );
final RandomAccessibleInterval< ARGBType > flybrain = ImageJFunctions.wrapRGBA( imp );

AffineTransform3D transform = new AffineTransform3D();
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/bvv/vistools/examples/Example07.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class Example07
*/
public static void main( final String[] args )
{
final ImagePlus imp = IJ.openImage( "https://imagej.nih.gov/ij/images/t1-head.zip" );
final ImagePlus imp = IJ.openImage( "https://imagej.net/ij/images/t1-head.zip" );
final Img< UnsignedShortType > img = ImageJFunctions.wrapShort( imp );

final BvvSource source = BvvFunctions.show( img, "t1-head",
Expand Down
Loading