Class BinaryThinning

java.lang.Object
boofcv.alg.filter.binary.impl.BinaryThinning

public class BinaryThinning extends Object
Applies binary thinning operators to the input image. Thinning discards most of objects foreground (value one) pixels and leaves behind a "skinny" object which still mostly describes the original object's shape. This implementation is known as the morphological thinning. It works by applying 8 masks to the image sequence. When a mask is applied pixels which need to be set to zero are recorded in a list. After the mask as been applied the pixels are modified, then the next mask is applied. This cycle is repeated until the image no longer changes. Based off the description in [1] using masks from [2]. The masks in those two sources are very similar but there is a one pixel difference which appears to create a smoother image in a couple of test cases.
  1. Rafael C. Gonzalez and Richard E. Woods, "Digital Image Processing" 2nd Ed. 2001.
  2. http://homepages.inf.ed.ac.uk/rbf/HIPR2/thin.htm, October 31, 2015
  • Field Details

    • mask0

      public static byte[] mask0
    • mask1

      public static byte[] mask1
    • mask2

      public static byte[] mask2
    • mask3

      public static byte[] mask3
    • mask4

      public static byte[] mask4
    • mask5

      public static byte[] mask5
    • mask6

      public static byte[] mask6
    • mask7

      public static byte[] mask7
  • Constructor Details

    • BinaryThinning

      public BinaryThinning()
  • Method Details

    • apply

      public void apply(GrayU8 binary, int maxLoops)
      Applies the thinning algorithm. Runs for the specified number of loops or until no change is detected.
      Parameters:
      binary - Input binary image which is to be thinned. This is modified
      maxLoops - Maximum number of thinning loops. Set to -1 to run until the image is no longer modified.
    • findOnePixels

      protected void findOnePixels(DogArray_I32 ones)
      Scans through the image and record the array index of all marked pixels