Class ConvertToMat
Object
org.anchoranalysis.plugin.opencv.convert.ConvertToMat
public class ConvertToMat extends Object
Converts common image data-structures used by Anchor to the
Mat class used by OpenCV.- Author:
- Owen Feehan
-
Method Summary
Modifier and Type Method Description static org.opencv.core.MatcreateEmptyMat(org.anchoranalysis.spatial.box.Extent extent, int type)Creates aMatwhich contains only zero-values.static org.opencv.core.MatfromObject(org.anchoranalysis.image.voxel.object.ObjectMask object)Convert aObjectMaskto aMat.static org.opencv.core.MatfromStack(org.anchoranalysis.image.core.stack.Stack stack)Converts aStackto aMat.static org.opencv.core.MatfromVoxelBufferByte(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)Converts aVoxelBufferof typeUnsignedByteBufferto aMat.static org.opencv.core.MatfromVoxelBufferFloat(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<FloatBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)static org.opencv.core.MatfromVoxelBufferShort(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)Converts aVoxelBufferof typeUnsignedShortBufferto aMat.static org.opencv.core.MatfromVoxelsByte(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxels)Converts aVoxelsof typeUnsignedByteBufferto aMat.static org.opencv.core.MatfromVoxelsFloat(org.anchoranalysis.image.voxel.Voxels<FloatBuffer> voxels)static org.opencv.core.MatfromVoxelsShort(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxels)Converts aVoxelsof typeUnsignedShortBufferto aMat.static org.opencv.core.MatmakeRGBStack(org.anchoranalysis.image.core.stack.Stack stack, boolean swapRedBlueChannels)Derives aMatrepresenting an RGB stack.
-
Method Details
-
fromObject
public static org.opencv.core.Mat fromObject(org.anchoranalysis.image.voxel.object.ObjectMask object) throws org.anchoranalysis.core.exception.CreateExceptionConvert aObjectMaskto aMat.- Parameters:
object- the object to convert.- Returns:
- a newly created
Matcontaining the voxels in the mask of theObjectMask. - Throws:
org.anchoranalysis.core.exception.CreateException- if the object is 3D, which is unsupported.
-
fromStack
public static org.opencv.core.Mat fromStack(org.anchoranalysis.image.core.stack.Stack stack) throws org.anchoranalysis.core.exception.CreateExceptionConverts 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:
org.anchoranalysis.core.exception.CreateException- if the stack is 3D, or has an invalid number of channels.
-
fromVoxelsByte
public static org.opencv.core.Mat fromVoxelsByte(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxels)Converts aVoxelsof typeUnsignedByteBufferto aMat.- Parameters:
voxels- the voxels to convert.- Returns:
- a newly created
Mat.
-
fromVoxelsShort
public static org.opencv.core.Mat fromVoxelsShort(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxels)Converts aVoxelsof typeUnsignedShortBufferto aMat.- Parameters:
voxels- the voxels to convert.- Returns:
- a newly created
Mat.
-
fromVoxelsFloat
public static org.opencv.core.Mat fromVoxelsFloat(org.anchoranalysis.image.voxel.Voxels<FloatBuffer> voxels)- Parameters:
voxels- the voxels to convert.- Returns:
- a newly created
Mat.
-
fromVoxelBufferByte
public static org.opencv.core.Mat fromVoxelBufferByte(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)Converts aVoxelBufferof typeUnsignedByteBufferto aMat.- 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(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)Converts aVoxelBufferof typeUnsignedShortBufferto aMat.- 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(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<FloatBuffer> voxelBuffer, org.anchoranalysis.spatial.box.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(org.anchoranalysis.image.core.stack.Stack stack, boolean swapRedBlueChannels) throws org.anchoranalysis.core.exception.CreateExceptionDerives 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:
org.anchoranalysis.core.exception.CreateException- if the stack does not have exactly three channels.
-
createEmptyMat
public static org.opencv.core.Mat createEmptyMat(org.anchoranalysis.spatial.box.Extent extent, int type)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.
-