Class ThresholdBlock<T extends boofcv.struct.image.ImageGray<T>,S extends boofcv.struct.image.ImageBase<S>>
- java.lang.Object
-
- boofcv.alg.filter.binary.ThresholdBlock<T,S>
-
- All Implemented Interfaces:
InputToBinary<T>
- Direct Known Subclasses:
ThresholdBlock_MT
public class ThresholdBlock<T extends boofcv.struct.image.ImageGray<T>,S extends boofcv.struct.image.ImageBase<S>> extends java.lang.Object implements InputToBinary<T>
Computes image statistics in regularly spaced blocks across the image. Then computes an average of the statistics in a block within a local 3x3 grid region. The average statistics in a local 3x3 grid region is used to reduce the adverse affects of using a grid. Ideally a local region around each pixel would be used, but this is expensive to compute. Since a grid is used instead of a pixel local region boundary conditions can be an issue. For example, consider a black square in the image, if the grid just happens to lie on this black square perfectly then if you look at only a single grid element it will be considered textureless and the edge lost. This problem isn't an issue if you consder a local 3x3 region of blocks.
The size each block in the grid in pixels is adjusted depending on image size. This is done to minimize "squares" in the upper image boundaries from having many more pixels than other blocks.
The block based approach used here was inspired by a high level description found in AprilTags.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceThresholdBlock.BlockProcessor<T extends boofcv.struct.image.ImageGray<T>,S extends boofcv.struct.image.ImageBase<S>>
-
Field Summary
Fields Modifier and Type Field Description protected intblockHeightprotected intblockWidthprotected ThresholdBlock.BlockProcessor<T,S>originalprotected boofcv.struct.lists.RecycleStack<ThresholdBlock.BlockProcessor<T,S>>processorsprotected boofcv.struct.ConfigLengthrequestedBlockWidthprotected Sstatsprotected booleanthresholdFromLocalBlocks
-
Constructor Summary
Constructors Constructor Description ThresholdBlock(ThresholdBlock.BlockProcessor<T,S> processor, boofcv.struct.ConfigLength requestedBlockWidth, boolean thresholdFromLocalBlocks, java.lang.Class<T> imageClass)Configures the detector
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyThreshold(T input, boofcv.struct.image.GrayU8 output)Applies the dynamically computed threshold to each pixel in the image, one block at a timeprotected voidcomputeStatistics(T input, int innerWidth, int innerHeight)Computes the min-max value for each block in the imageboofcv.struct.image.ImageType<T>getInputType()booleanisThresholdFromLocalBlocks()voidprocess(T input, boofcv.struct.image.GrayU8 output)Converts the gray scale input image into a binary imagevoidsetThresholdFromLocalBlocks(boolean thresholdFromLocalBlocks)
-
-
-
Field Detail
-
requestedBlockWidth
protected boofcv.struct.ConfigLength requestedBlockWidth
-
blockWidth
protected int blockWidth
-
blockHeight
protected int blockHeight
-
thresholdFromLocalBlocks
protected boolean thresholdFromLocalBlocks
-
original
protected ThresholdBlock.BlockProcessor<T extends boofcv.struct.image.ImageGray<T>,S extends boofcv.struct.image.ImageBase<S>> original
-
processors
protected boofcv.struct.lists.RecycleStack<ThresholdBlock.BlockProcessor<T extends boofcv.struct.image.ImageGray<T>,S extends boofcv.struct.image.ImageBase<S>>> processors
-
-
Constructor Detail
-
ThresholdBlock
public ThresholdBlock(ThresholdBlock.BlockProcessor<T,S> processor, boofcv.struct.ConfigLength requestedBlockWidth, boolean thresholdFromLocalBlocks, java.lang.Class<T> imageClass)
Configures the detector- Parameters:
requestedBlockWidth- About how wide and tall you wish a block to be in pixels.
-
-
Method Detail
-
process
public void process(T input, boofcv.struct.image.GrayU8 output)
Converts the gray scale input image into a binary image- Specified by:
processin interfaceInputToBinary<T extends boofcv.struct.image.ImageGray<T>>- Parameters:
input- Input imageoutput- Output binary image
-
applyThreshold
protected void applyThreshold(T input, boofcv.struct.image.GrayU8 output)
Applies the dynamically computed threshold to each pixel in the image, one block at a time
-
computeStatistics
protected void computeStatistics(T input, int innerWidth, int innerHeight)
Computes the min-max value for each block in the image
-
isThresholdFromLocalBlocks
public boolean isThresholdFromLocalBlocks()
-
setThresholdFromLocalBlocks
public void setThresholdFromLocalBlocks(boolean thresholdFromLocalBlocks)
-
getInputType
public boofcv.struct.image.ImageType<T> getInputType()
- Specified by:
getInputTypein interfaceInputToBinary<T extends boofcv.struct.image.ImageGray<T>>
-
-