Class ToUnsignedByteWithScaling
- Direct Known Subclasses:
UnsignedByteFromUnsignedByteNoInterleavingScale
,UnsignedByteFromUnsignedInt
,UnsignedByteFromUnsignedShort
Like
ToUnsignedByte
but applies scaling, if necessary, to map the original value to
8-bits.- Author:
- Owen Feehan
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ApplyScaling
The additional scaling that is applied during conversion.Fields inherited from class org.anchoranalysis.io.bioformats.copyconvert.ConvertTo
destinationSize, extent, sourceIncrement, sourceSize
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
ToUnsignedByteWithScaling
(int effectiveBits) Create with the number of bits that are used in the input-type. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
copyChangeOrientation
(ByteBuffer source, boolean littleEndian, int channelIndexRelative, UnsignedByteBuffer destination, OrientationChange orientationCorrection) Copy the bytes, changing orientation.protected void
copyKeepOrientation
(ByteBuffer source, boolean littleEndian, int channelIndexRelative, UnsignedByteBuffer destination) Copy the bytes, without changing orientation.protected abstract int
extractScaledValue
(byte[] sourceArray, int index, boolean littleEndian) Extracts a value from the source-array, and apply any scaling and clamping.protected boolean
Whether the source buffer can encode more than one channel?Methods inherited from class org.anchoranalysis.io.bioformats.copyconvert.ConvertTo
bytesPerVoxel, convert, convertSliceOfSingleChannel, copyAllChannels, setupBefore
-
Field Details
-
scaling
protected final ApplyScaling scalingThe additional scaling that is applied during conversion.
-
-
Constructor Details
-
ToUnsignedByteWithScaling
protected ToUnsignedByteWithScaling(int effectiveBits) Create with the number of bits that are used in the input-type.e.g. 8 or 12 or 16.
This should always be a positive number.
If
> 8
, then scaling is applied to values, to map them to the 8-bits available in an unsigned-byte.If
<= 8
, then no scaling is applied.- Parameters:
effectiveBits
- the number of bits that are used in the input-byte, from which a scaling factor is derived.
-
-
Method Details
-
supportsMultipleChannelsPerSourceBuffer
protected boolean supportsMultipleChannelsPerSourceBuffer()Description copied from class:ConvertTo
Whether the source buffer can encode more than one channel?- Specified by:
supportsMultipleChannelsPerSourceBuffer
in classConvertTo<UnsignedByteBuffer>
- Returns:
- true if this possible (either with interleaving or with RGB-encoded voxels), false if a buffer will always describe one channel only.
-
copyKeepOrientation
protected void copyKeepOrientation(ByteBuffer source, boolean littleEndian, int channelIndexRelative, UnsignedByteBuffer destination) Description copied from class:ConvertTo
Copy the bytes, without changing orientation.This is kept separate to
ConvertTo.copyChangeOrientation(java.nio.ByteBuffer, boolean, int, T, org.anchoranalysis.image.core.dimensions.OrientationChange)
as it can be done slightly more efficiently.- Specified by:
copyKeepOrientation
in classConvertTo<UnsignedByteBuffer>
- Parameters:
source
- the buffer we copy all channels from.littleEndian
- true iff the bytes insource
are in little-endian order.channelIndexRelative
- 0 if the buffer is non interleaved, or otherwise the index of the channel among the interleaved channels.destination
- finds an appropriate destination channel for a particular relative-channel-index.
-
copyChangeOrientation
protected void copyChangeOrientation(ByteBuffer source, boolean littleEndian, int channelIndexRelative, UnsignedByteBuffer destination, OrientationChange orientationCorrection) Description copied from class:ConvertTo
Copy the bytes, changing orientation.- Specified by:
copyChangeOrientation
in classConvertTo<UnsignedByteBuffer>
- Parameters:
source
- the buffer we copy all channels from.littleEndian
- true iff the bytes insource
are in little-endian order.channelIndexRelative
- 0 if the buffer is non interleaved, or otherwise the index of the channel among the interleaved channels.destination
- finds an appropriate destination channel for a particular relative-channel-index.orientationCorrection
- any correction of orientation to be applied as bytes are converted.
-
extractScaledValue
protected abstract int extractScaledValue(byte[] sourceArray, int index, boolean littleEndian) Extracts a value from the source-array, and apply any scaling and clamping.- Parameters:
sourceArray
- the bytes from which some values are extracted.index
- the offset insourceArray
from which a value is read.littleEndian
- true iff the bytes insource
are in little-endian order.- Returns:
- the extracted value.
-