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.MatcreateEmptyMat(Extent extent, int type) Creates aMatwhich contains only zero-values.static org.opencv.core.MatfromObject(ObjectMask object) Convert aObjectMaskto aMat.static org.opencv.core.MatConverts aStackto aMat.static org.opencv.core.MatfromVoxelBufferByte(VoxelBuffer<UnsignedByteBuffer> voxelBuffer, Extent extent) static org.opencv.core.MatfromVoxelBufferFloat(VoxelBuffer<FloatBuffer> voxelBuffer, Extent extent) static org.opencv.core.MatfromVoxelBufferShort(VoxelBuffer<UnsignedShortBuffer> voxelBuffer, Extent extent) static org.opencv.core.MatfromVoxelsByte(Voxels<UnsignedByteBuffer> voxels) static org.opencv.core.MatfromVoxelsFloat(Voxels<FloatBuffer> voxels) static org.opencv.core.MatfromVoxelsShort(Voxels<UnsignedShortBuffer> voxels) static org.opencv.core.MatmakeRGBStack(Stack stack, boolean swapRedBlueChannels) Derives aMatrepresenting an RGB stack.
-
Method Details
-
fromObject
Convert aObjectMaskto aMat.- Parameters:
object- the object to convert.- Returns:
- a newly created
Matcontaining the voxels in the mask of theObjectMask. - Throws:
CreateException- if the object is 3D, which is unsupported.
-
fromStack
Converts aStackto 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
Matwith identical voxels toStack. In the case of an RGB image, theMathas 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 aMatrepresenting an RGB stack.- Parameters:
stack- a stack containing three channels.swapRedBlueChannels- if true, the first channel and third channel instackare swapped to make theMatto e.g. translate RGB to BGR (as expected by OpenCV).- Returns:
- a newly created
Matrepresentation ofstack. - Throws:
CreateException- if the stack does not have exactly three channels.
-
createEmptyMat
Creates aMatwhich contains only zero-values.- Parameters:
extent- the size of theMatto create.type- a OpenCV type constant indicating the data-type of the voxels inMat.- Returns:
- the newly created
Mat.
-