Class ConvertToMat

Object
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 Details

    • fromObject

      public static org.opencv.core.Mat fromObject(ObjectMask object) throws CreateException
      Convert a ObjectMask to a Mat.
      Parameters:
      object - the object to convert.
      Returns:
      a newly created Mat containing the voxels in the mask of the ObjectMask.
      Throws:
      CreateException - if the object is 3D, which is unsupported.
    • fromStack

      public static org.opencv.core.Mat fromStack(Stack stack) throws CreateException
      Converts a Stack to a Mat.
      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 to Stack. In the case of an RGB image, the Mat has BGR channel ordering.
      Throws:
      CreateException - if the stack is 3D, or has an invalid number of channels.
    • fromVoxelsByte

      public static org.opencv.core.Mat fromVoxelsByte(Voxels<UnsignedByteBuffer> voxels)
      Converts a Voxels of type UnsignedByteBuffer to a Mat.
      Parameters:
      voxels - the voxels to convert.
      Returns:
      a newly created Mat.
    • fromVoxelsShort

      public static org.opencv.core.Mat fromVoxelsShort(Voxels<UnsignedShortBuffer> voxels)
      Converts a Voxels of type UnsignedShortBuffer to a Mat.
      Parameters:
      voxels - the voxels to convert.
      Returns:
      a newly created Mat.
    • fromVoxelsFloat

      public static org.opencv.core.Mat fromVoxelsFloat(Voxels<FloatBuffer> voxels)
      Converts a Voxels of type FloatBuffer to a Mat.
      Parameters:
      voxels - the voxels to convert.
      Returns:
      a newly created Mat.
    • fromVoxelBufferByte

      public static org.opencv.core.Mat fromVoxelBufferByte(VoxelBuffer<UnsignedByteBuffer> voxelBuffer, Extent extent)
      Converts a VoxelBuffer of type UnsignedByteBuffer to a Mat.
      Parameters:
      voxelBuffer - the voxel-buffer to convert.
      extent - the size of the image the buffer represents (must have identical number of voxels to voxelBuffer.
      Returns:
      a newly created Mat.
    • fromVoxelBufferShort

      public static org.opencv.core.Mat fromVoxelBufferShort(VoxelBuffer<UnsignedShortBuffer> voxelBuffer, Extent extent)
      Converts a VoxelBuffer of type UnsignedShortBuffer to a Mat.
      Parameters:
      voxelBuffer - the voxel-buffer to convert.
      extent - the size of the image the buffer represents (must have identical number of voxels to voxelBuffer.
      Returns:
      a newly created Mat.
    • fromVoxelBufferFloat

      public static org.opencv.core.Mat fromVoxelBufferFloat(VoxelBuffer<FloatBuffer> voxelBuffer, Extent extent)
      Converts a VoxelBuffer of type FloatBuffer to a Mat.
      Parameters:
      voxelBuffer - the voxel-buffer to convert.
      extent - the size of the image the buffer represents (must have identical number of voxels to voxelBuffer.
      Returns:
      a newly created Mat.
    • makeRGBStack

      public static org.opencv.core.Mat makeRGBStack(Stack stack, boolean swapRedBlueChannels) throws CreateException
      Derives a Mat representing an RGB stack.
      Parameters:
      stack - a stack containing three channels.
      swapRedBlueChannels - if true, the first channel and third channel in stack are swapped to make the Mat to e.g. translate RGB to BGR (as expected by OpenCV).
      Returns:
      a newly created Mat representation of stack.
      Throws:
      CreateException - if the stack does not have exactly three channels.
    • createEmptyMat

      public static org.opencv.core.Mat createEmptyMat(Extent extent, int type)
      Creates a Mat which contains only zero-values.
      Parameters:
      extent - the size of the Mat to create.
      type - a OpenCV type constant indicating the data-type of the voxels in Mat.
      Returns:
      the newly created Mat.