Module NewOCR

Class SegmentationUtils


  • public class SegmentationUtils
    extends java.lang.Object
    A utility class for methods to create segments separating character images for training and scanning.
    Since:
    April 25, 2019
    • Method Summary

      Modifier and Type Method Description
      static java.util.List<IntPair> getDiagonal​(boolean[][] values, boolean increasing)
      Splits a grid of values in half diagonally.
      static java.util.stream.Stream<boolean[][]> getHorizontalHalf​(boolean[][] values)
      Splits a grid of values in half horizontally
      static java.util.stream.Stream<boolean[][]> getHorizontalThird​(boolean[][] values)
      Splits a grid of values in thirds horizontally
      static java.util.stream.Stream<boolean[][]> getVerticalHalf​(boolean[][] values)
      Splits a grid of values in half vertically
      static java.util.stream.Stream<IntPair> getVerticalThird​(boolean[][] values)
      Splits a grid of values in thirds vertically
      • Methods inherited from class java.lang.Object

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

      • ZERO_PLACEHOLDER

        public static final IntPair ZERO_PLACEHOLDER
    • Constructor Detail

      • SegmentationUtils

        public SegmentationUtils()
    • Method Detail

      • getHorizontalHalf

        public static java.util.stream.Stream<boolean[][]> getHorizontalHalf​(boolean[][] values)
        Splits a grid of values in half horizontally
        Parameters:
        values - The grid to split
        Returns:
        A stream of 2 halves, top and bottom
      • getHorizontalThird

        public static java.util.stream.Stream<boolean[][]> getHorizontalThird​(boolean[][] values)
        Splits a grid of values in thirds horizontally
        Parameters:
        values - The grid to split
        Returns:
        A stream of 3 thirds: top, middle, and bottom
      • getVerticalHalf

        public static java.util.stream.Stream<boolean[][]> getVerticalHalf​(boolean[][] values)
        Splits a grid of values in half vertically
        Parameters:
        values - The grid to split
        Returns:
        A stream of 2 halves, left and right
      • getVerticalThird

        public static java.util.stream.Stream<IntPair> getVerticalThird​(boolean[][] values)
        Splits a grid of values in thirds vertically
        Parameters:
        values - The grid to split
        Returns:
        A stream of 3 thirds: left, middle, and right
      • getDiagonal

        public static java.util.List<IntPair> getDiagonal​(boolean[][] values,
                                                          boolean increasing)
        Splits a grid of values in half diagonally. The diagonal line will be going from the top left to bottom right if `increasing` is `true`, and top left to bottom right if it is `false`.
        Parameters:
        values - The grid to split into halves diagonally
        increasing - The line's slope will be positive when `true`, and negative when `false`.
        Returns:
        A List of 2 halves