HybridBinarizer (ZXing 3.5.2 API)
Description: declaration: package: com.google.zxing.common, class: HybridBinarizer

Package com.google.zxing.common

# Class HybridBinarizer

java.lang.Object
com.google.zxing.Binarizer
com.google.zxing.common.GlobalHistogramBinarizer
com.google.zxing.common.HybridBinarizer

public final class HybridBinarizer extends GlobalHistogramBinarizer
This class implements a local thresholding algorithm, which while slower than the GlobalHistogramBinarizer, is fairly efficient for what it does. It is designed for high frequency images of barcodes with black data on white backgrounds. For this application, it does a much better job than a global blackpoint with severe shadows and gradients. However it tends to produce artifacts on lower frequency images and is therefore not a good general purpose binarizer for uses outside ZXing. This class extends GlobalHistogramBinarizer, using the older histogram approach for 1D readers, and the newer local approach for 2D readers. 1D decoding using a per-row histogram is already inherently local, and only fails for horizontal gradients. We can revisit that problem later, but for now it was not a win to use local blocks for 1D. This Binarizer is the default for the unit tests and the recommended class for library users.

Author:
  dswitkin@google.com (Daniel Switkin)

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `HybridBinarizer(LuminanceSource source)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Binarizer`
  `createBinarizer(LuminanceSource source)`
  Creates a new object with the same type as this Binarizer implementation, but with pristine state.
  `BitMatrix`
  `getBlackMatrix()`
  Calculates the final BitMatrix once for all requests.

  ### Methods inherited from class com.google.zxing.common.GlobalHistogramBinarizer

  `getBlackRow`

  ### Methods inherited from class com.google.zxing.Binarizer

  `getHeight, getLuminanceSource, getWidth`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### HybridBinarizer

    public HybridBinarizer(LuminanceSource source)

- ## Method Details

  - ### getBlackMatrix

    public BitMatrix getBlackMatrix() throws NotFoundException
    Calculates the final BitMatrix once for all requests. This could be called once from the constructor instead, but there are some advantages to doing it lazily, such as making profiling easier, and not doing heavy lifting when callers don't expect it.
    Overrides:
      `getBlackMatrix` in class `GlobalHistogramBinarizer`
    Returns:
      The 2D array of bits for the image (true means black).
    Throws:
      `NotFoundException` - if image can't be binarized to make a matrix

  - ### createBinarizer

    public Binarizer createBinarizer(LuminanceSource source)
    Description copied from class: `Binarizer`
    Creates a new object with the same type as this Binarizer implementation, but with pristine state. This is needed because Binarizer implementations may be stateful, e.g. keeping a cache of 1 bit data. See Effective Java for why we can't use Java's clone() method.
    Overrides:
      `createBinarizer` in class `GlobalHistogramBinarizer`
    Parameters:
      `source` - The LuminanceSource this Binarizer will operate on.
    Returns:
      A new concrete Binarizer implementation object.