Class ThresholdBlockOtsu

  • All Implemented Interfaces:
    ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>

    public class ThresholdBlockOtsu
    extends java.lang.Object
    implements ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>
    Block Otsu threshold implementation based on ThresholdBlock. Computes a histogram in non-overlapping square regions. Then thresholds a single region by combining histograms from its neighbors to make it less blocky. This implementation includes a modification from the traditional Otsu algorithm. The threshold can optionally be adjusted in low variance regions. See code for details.

    NOTE: This produces visually different results from ThresholdBlockOtsu because the block algorithm combines histograms from its neighboring blocks. That's why it appears to have a wider effective block.

    See Also:
    GThresholdImageOps.computeOtsu(ImageGray, double, double)
    • Constructor Summary

      Constructors 
      Constructor Description
      ThresholdBlockOtsu​(boolean otsu2, double tuning, double scale, boolean down)
      Configures the detector
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void computeBlockStatistics​(int x0, int y0, int width, int height, int indexStats, boofcv.struct.image.GrayU8 input, boofcv.struct.image.InterleavedS32 stats)
      Computes the min-max value inside a block
      ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32> copy()
      Creates a copy.
      boofcv.struct.image.InterleavedS32 createStats()  
      void init​(int blockWidth, int blockHeight, boolean thresholdFromLocalBlocks)  
      void thresholdBlock​(int blockX0, int blockY0, boofcv.struct.image.GrayU8 input, boofcv.struct.image.InterleavedS32 stats, boofcv.struct.image.GrayU8 output)
      Thresholds all the pixels inside the specified block
      • Methods inherited from class java.lang.Object

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

      • blockWidth

        protected int blockWidth
      • blockHeight

        protected int blockHeight
      • thresholdFromLocalBlocks

        protected boolean thresholdFromLocalBlocks
    • Constructor Detail

      • ThresholdBlockOtsu

        public ThresholdBlockOtsu​(boolean otsu2,
                                  double tuning,
                                  double scale,
                                  boolean down)
        Configures the detector
        Parameters:
        tuning - Tuning parameter. 0 = standard Otsu. Greater than 0 will penalize zero texture.
    • Method Detail

      • createStats

        public boofcv.struct.image.InterleavedS32 createStats()
        Specified by:
        createStats in interface ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>
      • init

        public void init​(int blockWidth,
                         int blockHeight,
                         boolean thresholdFromLocalBlocks)
        Specified by:
        init in interface ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>
      • computeBlockStatistics

        public void computeBlockStatistics​(int x0,
                                           int y0,
                                           int width,
                                           int height,
                                           int indexStats,
                                           boofcv.struct.image.GrayU8 input,
                                           boofcv.struct.image.InterleavedS32 stats)
        Description copied from interface: ThresholdBlock.BlockProcessor
        Computes the min-max value inside a block
        Specified by:
        computeBlockStatistics in interface ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>
        Parameters:
        x0 - lower bound pixel value of block, x-axis
        y0 - upper bound pixel value of block, y-axis
        width - Block's width
        height - Block's height
        indexStats - array index of statistics image pixel
        input - Input image
      • thresholdBlock

        public void thresholdBlock​(int blockX0,
                                   int blockY0,
                                   boofcv.struct.image.GrayU8 input,
                                   boofcv.struct.image.InterleavedS32 stats,
                                   boofcv.struct.image.GrayU8 output)
        Description copied from interface: ThresholdBlock.BlockProcessor
        Thresholds all the pixels inside the specified block
        Specified by:
        thresholdBlock in interface ThresholdBlock.BlockProcessor<boofcv.struct.image.GrayU8,​boofcv.struct.image.InterleavedS32>
        Parameters:
        blockX0 - Block x-coordinate
        blockY0 - Block y-coordinate
        input - Input image
        output - Output image