Class Mask


  • public class Mask
    extends java.lang.Object
    Provides some utility methods for dealing with mask ROIs.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static MaskData createCroppedMask​(boolean[][] mask)
      Creates a mask ROI; automatically crop to its bounding box.
      static MaskData createCroppedMask​(int[][] mask)
      Creates a mask ROI; automatically crop to its bounding box.
      static java.util.List<MaskData> createCroppedMasks​(int[][] masks)
      Creates mask ROIs from the given integer array where each single mask ROI is specified by a specific integer.
      static java.util.List<MaskData> createCroppedMasks​(int[] masks, int width)
      Creates mask ROIs from the given integer array where each single mask ROI is specified by a specific integer.
      static int[][] fold​(int[] array, int length)
      Breaks a one-dimensional array into 'length' chunks, forming a two-dimensional array, e.g.
      static int[] unfold​(int[][] array)
      Transforms a 2 dimensional array into a one dimensional array; the opposite of the fold method.
      • Methods inherited from class java.lang.Object

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

      • createCroppedMask

        public static MaskData createCroppedMask​(int[][] mask)
        Creates a mask ROI; automatically crop to its bounding box. (sets X, Y, width and height accordingly)
        Parameters:
        mask - The binary mask (int[width][height]) covering the whole image
        Returns:
        The mask ROI
      • createCroppedMask

        public static MaskData createCroppedMask​(boolean[][] mask)
        Creates a mask ROI; automatically crop to its bounding box. (sets X, Y, width and height accordingly)
        Parameters:
        mask - The binary mask (boolean[width][height]) covering the whole image
        Returns:
        The mask ROI
      • createCroppedMasks

        public static java.util.List<MaskData> createCroppedMasks​(int[][] masks)
        Creates mask ROIs from the given integer array where each single mask ROI is specified by a specific integer.
        Parameters:
        masks - The masks (int[width][height]) covering the whole image.
        Returns:
        The mask ROIs
      • createCroppedMasks

        public static java.util.List<MaskData> createCroppedMasks​(int[] masks,
                                                                  int width)
        Creates mask ROIs from the given integer array where each single mask ROI is specified by a specific integer.
        Parameters:
        masks - The masks covering the whole image.
        width - The width of the image
        Returns:
        The mask ROIs
      • fold

        public static int[][] fold​(int[] array,
                                   int length)
        Breaks a one-dimensional array into 'length' chunks, forming a two-dimensional array, e.g.
         int[] x = 0 1 2 3 4 5 6 7 8 9
        
         using length = 4 will be transformed to
        
         int[][] y =
         [0 1 2 3]
         [4 5 6 7]
         [8 9 0 0]
         
        Parameters:
        array - An int array
        length - The length of the chunks
        Returns:
        Two dimensional array
      • unfold

        public static int[] unfold​(int[][] array)
        Transforms a 2 dimensional array into a one dimensional array; the opposite of the fold method. E.g.
         int[][] y =
         [0 1 2 3]
         [4 5 6 7]
         [8 9 0 0]
        
         would transformed into
        
         int[] x = 0 1 2 3 4 5 6 7 8 9 0 0
         
        Parameters:
        array - An int array
        Returns:
        The one dimensional array