Class MaskUtil


  • final class MaskUtil
    extends java.lang.Object
    • Constructor Detail

      • MaskUtil

        private MaskUtil()
    • Method Detail

      • applyMaskPenaltyRule1

        public static int applyMaskPenaltyRule1​(ByteMatrix matrix)
        Apply mask penalty rule 1 and return the penalty. Find repetitive cells with the same color and give penalty to them. Example: 00000 or 11111.
        Parameters:
        matrix - ByteMatrix to apply the penalty rule to
        Returns:
        the rule 1 penalty
      • applyMaskPenaltyRule2

        public static int applyMaskPenaltyRule2​(ByteMatrix matrix)
        Apply mask penalty rule 2 and return the penalty. Find 2x2 blocks with the same color and give penalty to them.
        Parameters:
        matrix - ByteMatrix to apply the penalty rule to
        Returns:
        the rule 2 penalty
      • applyMaskPenaltyRule3

        public static int applyMaskPenaltyRule3​(ByteMatrix matrix)
        Apply mask penalty rule 3 and return the penalty. Find consecutive cells of 00001011101 or 10111010000, and give penalty to them. If we find patterns like 000010111010000, we give penalties twice (i.e. 40 * 2).
        Parameters:
        matrix - ByteMatrix to apply the penalty rule to
        Returns:
        the rule 3 penalty
      • applyMaskPenaltyRule4

        public static int applyMaskPenaltyRule4​(ByteMatrix matrix)
        Apply mask penalty rule 4 and return the penalty. Calculate the ratio of dark cells and give penalty if the ratio is far from 50%. It gives 10 penalty for 5% distance. Examples: - 0% => 100 - 40% => 20 - 45% => 10 - 50% => 0 - 55% => 10 - 55% => 20 - 100% => 100
        Parameters:
        matrix - Bytematrix to apply the rule to
        Returns:
        the rule 4 penalty
      • getDataMaskBit

        public static boolean getDataMaskBit​(int maskPattern,
                                             int x,
                                             int y)
        Return the mask bit for "getMaskPattern" at "x" and "y". See 8.8 of JISX0510:2004 for mask pattern conditions.
        Parameters:
        maskPattern - masking pattern to use
        x - width coordiante
        y - height-coordinate
        Returns:
        the mask bit at that position
      • applyMaskPenaltyRule1Internal

        private static int applyMaskPenaltyRule1Internal​(ByteMatrix matrix,
                                                         boolean isHorizontal)