T
- destination buffer-typepublic abstract class ConvertTo<T> extends Object
Modifier and Type | Field and Description |
---|---|
protected int |
destinationSize
The total number of elements (whatever the destination type is) in the destination buffer.
|
protected Extent |
extent
The size of the source and destination buffers.
|
protected int |
sourceIncrement
The number of elements (bytes) to increment by, when iterating through the source buffer.
|
protected int |
sourceSize
The total number of elements (always bytes) in the source buffer.
|
Constructor and Description |
---|
ConvertTo(java.util.function.Function<VoxelsUntyped,Voxels<T>> functionCast,
java.util.function.IntFunction<T> allocateBuffer,
java.util.function.Function<T,VoxelBuffer<T>> wrapBuffer) |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
bytesPerVoxel()
The number bytes to describe each source-voxel.
|
protected T |
convert(ByteBuffer source,
int channelIndexRelative,
OrientationChange orientationCorrection,
boolean littleEndian) |
protected VoxelBuffer<T> |
convertSliceOfSingleChannel(ByteBuffer source,
int channelIndexRelative,
OrientationChange orientationCorrection)
Converts a slice of single-channel into a newly created
VoxelBuffer . |
void |
copyAllChannels(Dimensions dimensions,
ByteBuffer source,
DestinationChannelForIndex destination,
int z,
ImageFileEncoding sourceImageEncoding,
OrientationChange orientationCorrection)
Copies the channels in the source buffer into a particular
DestinationChannelForIndex . |
protected abstract void |
copyChangeOrientation(ByteBuffer source,
boolean littleEndian,
int channelIndexRelative,
T destination,
OrientationChange orientationCorrection)
Copy the bytes, changing orientation.
|
protected abstract void |
copyKeepOrientation(ByteBuffer source,
boolean littleEndian,
int channelIndexRelative,
T destination)
Copy the bytes, without changing orientation.
|
protected void |
setupBefore(Dimensions dimensions,
ImageFileEncoding sourceImageEncoding)
Always called before any batch of calls to
convertSliceOfSingleChannel(java.nio.ByteBuffer, int, org.anchoranalysis.image.core.dimensions.OrientationChange) . |
protected abstract boolean |
supportsMultipleChannelsPerSourceBuffer()
Whether the source buffer can encode more than one channel?
|
protected Extent extent
protected int sourceIncrement
protected int sourceSize
protected int destinationSize
public ConvertTo(java.util.function.Function<VoxelsUntyped,Voxels<T>> functionCast, java.util.function.IntFunction<T> allocateBuffer, java.util.function.Function<T,VoxelBuffer<T>> wrapBuffer)
public void copyAllChannels(Dimensions dimensions, ByteBuffer source, DestinationChannelForIndex destination, int z, ImageFileEncoding sourceImageEncoding, OrientationChange orientationCorrection) throws IOException
DestinationChannelForIndex
.dimensions
- scene-dimension.source
- the buffer we copy all channels from.destination
- finds an appropriate destination channel for a particular
relative-channel-index.z
- the current slice we are working on.sourceImageEncoding
- how voxels are stored in the source-image.orientationCorrection
- any correction of orientation to be applied as bytes are
converted.IOException
- if any error occurs when copying channels.protected void setupBefore(Dimensions dimensions, ImageFileEncoding sourceImageEncoding) throws IOException
convertSliceOfSingleChannel(java.nio.ByteBuffer, int, org.anchoranalysis.image.core.dimensions.OrientationChange)
.dimensions
- the final dimensions of the image.sourceImageEncoding
- how voxels are stored in the source-image.IOException
- if a particular combination of parameters is unsupported.protected VoxelBuffer<T> convertSliceOfSingleChannel(ByteBuffer source, int channelIndexRelative, OrientationChange orientationCorrection) throws IOException
VoxelBuffer
.source
- source buffer containing the bytes we copy from.channelIndexRelative
- 0 if the buffer is non interleaved, or otherwise the index of the
channel among the interleaved channels.orientationCorrection
- any correction of orientation to be applied as bytes are
converted.IOException
- when operation is unsupported, given particular parameterization.protected T convert(ByteBuffer source, int channelIndexRelative, OrientationChange orientationCorrection, boolean littleEndian) throws IOException
IOException
protected abstract void copyKeepOrientation(ByteBuffer source, boolean littleEndian, int channelIndexRelative, T destination) throws IOException
This is kept separate to copyChangeOrientation(java.nio.ByteBuffer, boolean, int, T, org.anchoranalysis.image.core.dimensions.OrientationChange)
as it can be done slightly more
efficiently.
IOException
protected abstract void copyChangeOrientation(ByteBuffer source, boolean littleEndian, int channelIndexRelative, T destination, OrientationChange orientationCorrection) throws IOException
IOException
protected abstract boolean supportsMultipleChannelsPerSourceBuffer()
protected abstract int bytesPerVoxel()
Copyright © 2010–2023 Owen Feehan, ETH Zurich, University of Zurich, Hoffmann-La Roche. All rights reserved.