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.Mat createEmptyMat​(org.anchoranalysis.spatial.box.Extent extent, int type)
    Creates a Mat which contains only zero-values.
    static org.opencv.core.Mat fromObject​(org.anchoranalysis.image.voxel.object.ObjectMask object)
    Convert a ObjectMask to a Mat.
    static org.opencv.core.Mat fromStack​(org.anchoranalysis.image.core.stack.Stack stack)
    Converts a Stack to a Mat.
    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 a VoxelBuffer of type UnsignedByteBuffer to a Mat.
    static org.opencv.core.Mat fromVoxelBufferFloat​(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<FloatBuffer> voxelBuffer, org.anchoranalysis.spatial.box.Extent extent)
    Converts a VoxelBuffer of type FloatBuffer to a Mat.
    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 a VoxelBuffer of type UnsignedShortBuffer to a Mat.
    static org.opencv.core.Mat fromVoxelsByte​(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxels)
    Converts a Voxels of type UnsignedByteBuffer to a Mat.
    static org.opencv.core.Mat fromVoxelsFloat​(org.anchoranalysis.image.voxel.Voxels<FloatBuffer> voxels)
    Converts a Voxels of type FloatBuffer to a Mat.
    static org.opencv.core.Mat fromVoxelsShort​(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxels)
    Converts a Voxels of type UnsignedShortBuffer to a Mat.
    static org.opencv.core.Mat makeRGBStack​(org.anchoranalysis.image.core.stack.Stack stack, boolean swapRedBlueChannels)
    Derives a Mat representing an RGB stack.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • fromObject

      public static org.opencv.core.Mat fromObject​(org.anchoranalysis.image.voxel.object.ObjectMask object) throws org.anchoranalysis.core.exception.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:
      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.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:
      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 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​(org.anchoranalysis.image.voxel.Voxels<org.anchoranalysis.image.voxel.buffer.primitive.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​(org.anchoranalysis.image.voxel.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​(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedByteBuffer> voxelBuffer, org.anchoranalysis.spatial.box.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​(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<org.anchoranalysis.image.voxel.buffer.primitive.UnsignedShortBuffer> voxelBuffer, org.anchoranalysis.spatial.box.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​(org.anchoranalysis.image.voxel.buffer.VoxelBuffer<FloatBuffer> voxelBuffer, org.anchoranalysis.spatial.box.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​(org.anchoranalysis.image.core.stack.Stack stack, boolean swapRedBlueChannels) throws org.anchoranalysis.core.exception.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:
      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 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.