Class ThresholdSauvola_MT

  • All Implemented Interfaces:
    InputToBinary<boofcv.struct.image.GrayF32>

    public class ThresholdSauvola_MT
    extends java.lang.Object
    implements InputToBinary<boofcv.struct.image.GrayF32>

    Intended for use as a preprocessing step in OCR it computes a binary image from an input gray image. It's an adaptive algorithm and uses the local mean and standard deviation, as is shown in the equation below:
    T(x,y) = m(x,y) * [ 1 + k * (s(x,y)/R - 1)]
    where T(x,y) is the pixel's threshold, m(x,y) is the local mean, s(x,y) is the local deviation, R is dynamic range of standard deviation, and k is a user specified threshold.

    There are two tuning parameters 'k' a positive number and the the 'radius' of the local region. Recommended values are k=0.3 and radius=15. These were found by tuning against a set of text.

    • Constructor Summary

      Constructors 
      Constructor Description
      ThresholdSauvola_MT​(boofcv.struct.ConfigLength width, float k, boolean down)
      Configures the algorithm.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boofcv.struct.image.ImageType<boofcv.struct.image.GrayF32> getInputType()  
      float getK()  
      boofcv.struct.ConfigLength getWidth()  
      boolean isDown()  
      void process​(boofcv.struct.image.GrayF32 input, boofcv.struct.image.GrayU8 output)
      Converts the input image into a binary image.
      void setDown​(boolean down)  
      void setK​(float k)  
      void setWidth​(boofcv.struct.ConfigLength width)  
      • Methods inherited from class java.lang.Object

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

      • ThresholdSauvola_MT

        public ThresholdSauvola_MT​(boofcv.struct.ConfigLength width,
                                   float k,
                                   boolean down)
        Configures the algorithm.
        Parameters:
        width - size of local region. Try 31
        k - User specified threshold adjustment factor. Must be positive. Try 0.3
        down - Threshold down or up
    • Method Detail

      • process

        public void process​(boofcv.struct.image.GrayF32 input,
                            boofcv.struct.image.GrayU8 output)
        Converts the input image into a binary image.
        Specified by:
        process in interface InputToBinary<boofcv.struct.image.GrayF32>
        Parameters:
        input - Input image. Not modified.
        output - Output binary image. Modified.
      • getInputType

        public boofcv.struct.image.ImageType<boofcv.struct.image.GrayF32> getInputType()
        Specified by:
        getInputType in interface InputToBinary<boofcv.struct.image.GrayF32>
      • getK

        public float getK()
      • setK

        public void setK​(float k)
      • getWidth

        public boofcv.struct.ConfigLength getWidth()
      • setWidth

        public void setWidth​(boofcv.struct.ConfigLength width)
      • isDown

        public boolean isDown()
      • setDown

        public void setDown​(boolean down)