Class ConvertToMat
Object
ConvertToMat
Converts common image data-structures used by Anchor to the
Mat
class used by OpenCV.- Author:
- Owen Feehan
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.opencv.core.Mat
createEmptyMat
(Extent extent, int type) Creates aMat
which contains only zero-values.static org.opencv.core.Mat
fromObject
(ObjectMask object) Convert aObjectMask
to aMat
.static org.opencv.core.Mat
Converts aStack
to aMat
.static org.opencv.core.Mat
fromVoxelBufferByte
(VoxelBuffer<UnsignedByteBuffer> voxelBuffer, Extent extent) static org.opencv.core.Mat
fromVoxelBufferFloat
(VoxelBuffer<FloatBuffer> voxelBuffer, Extent extent) static org.opencv.core.Mat
fromVoxelBufferShort
(VoxelBuffer<UnsignedShortBuffer> voxelBuffer, Extent extent) static org.opencv.core.Mat
fromVoxelsByte
(Voxels<UnsignedByteBuffer> voxels) static org.opencv.core.Mat
fromVoxelsFloat
(Voxels<FloatBuffer> voxels) static org.opencv.core.Mat
fromVoxelsShort
(Voxels<UnsignedShortBuffer> voxels) static org.opencv.core.Mat
makeRGBStack
(Stack stack, boolean swapRedBlueChannels) Derives aMat
representing an RGB stack.
-
Method Details
-
fromObject
Convert aObjectMask
to aMat
.- Parameters:
object
- the object to convert.- Returns:
- a newly created
Mat
containing the voxels in the mask of theObjectMask
. - Throws:
CreateException
- if the object is 3D, which is unsupported.
-
fromStack
Converts aStack
to aMat
.- Parameters:
stack
- the stack to convert, which must have 1 or 3 channels (in which case, it is presumed to be RGB).- Returns:
- a newly-created
Mat
with identical voxels toStack
. In the case of an RGB image, theMat
has BGR channel ordering. - Throws:
CreateException
- if the stack is 3D, or has an invalid number of channels.
-
fromVoxelsByte
- Parameters:
voxels
- the voxels to convert.- Returns:
- a newly created
Mat
.
-
fromVoxelsShort
- Parameters:
voxels
- the voxels to convert.- Returns:
- a newly created
Mat
.
-
fromVoxelsFloat
- Parameters:
voxels
- the voxels to convert.- Returns:
- a newly created
Mat
.
-
fromVoxelBufferByte
public static org.opencv.core.Mat fromVoxelBufferByte(VoxelBuffer<UnsignedByteBuffer> voxelBuffer, Extent extent) - Parameters:
voxelBuffer
- the voxel-buffer to convert.extent
- the size of the image the buffer represents (must have identical number of voxels tovoxelBuffer
.- Returns:
- a newly created
Mat
.
-
fromVoxelBufferShort
public static org.opencv.core.Mat fromVoxelBufferShort(VoxelBuffer<UnsignedShortBuffer> voxelBuffer, Extent extent) - Parameters:
voxelBuffer
- the voxel-buffer to convert.extent
- the size of the image the buffer represents (must have identical number of voxels tovoxelBuffer
.- Returns:
- a newly created
Mat
.
-
fromVoxelBufferFloat
public static org.opencv.core.Mat fromVoxelBufferFloat(VoxelBuffer<FloatBuffer> voxelBuffer, Extent extent) - Parameters:
voxelBuffer
- the voxel-buffer to convert.extent
- the size of the image the buffer represents (must have identical number of voxels tovoxelBuffer
.- Returns:
- a newly created
Mat
.
-
makeRGBStack
public static org.opencv.core.Mat makeRGBStack(Stack stack, boolean swapRedBlueChannels) throws CreateException Derives aMat
representing an RGB stack.- Parameters:
stack
- a stack containing three channels.swapRedBlueChannels
- if true, the first channel and third channel instack
are swapped to make theMat
to e.g. translate RGB to BGR (as expected by OpenCV).- Returns:
- a newly created
Mat
representation ofstack
. - Throws:
CreateException
- if the stack does not have exactly three channels.
-
createEmptyMat
Creates aMat
which contains only zero-values.- Parameters:
extent
- the size of theMat
to create.type
- a OpenCV type constant indicating the data-type of the voxels inMat
.- Returns:
- the newly created
Mat
.
-