public abstract class ThresholdBlockCommon<T extends ImageGray<T>,S extends 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.
| Modifier and Type | Field and Description |
|---|---|
protected int |
blockHeight |
protected int |
blockWidth |
protected ConfigLength |
requestedBlockWidth |
protected S |
stats |
protected boolean |
thresholdFromLocalBlocks |
| Constructor and Description |
|---|
ThresholdBlockCommon(ConfigLength requestedBlockWidth,
boolean thresholdFromLocalBlocks,
java.lang.Class<T> imageClass)
Configures the detector
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
computeBlockStatistics(int x0,
int y0,
int width,
int height,
int indexStats,
T input)
Computes the min-max value inside a block
|
protected void |
computeStatistics(T input,
int innerWidth,
int innerHeight)
Computes the min-max value for each block in the image
|
ImageType<T> |
getInputType() |
boolean |
isThresholdFromLocalBlocks() |
void |
process(T input,
GrayU8 output)
Converts the gray scale input image into a binary image
|
void |
setThresholdFromLocalBlocks(boolean thresholdFromLocalBlocks) |
protected abstract void |
thresholdBlock(int blockX0,
int blockY0,
T input,
GrayU8 output)
Thresholds all the pixels inside the specified block
|
protected ConfigLength requestedBlockWidth
protected int blockWidth
protected int blockHeight
protected boolean thresholdFromLocalBlocks
public ThresholdBlockCommon(ConfigLength requestedBlockWidth, boolean thresholdFromLocalBlocks, java.lang.Class<T> imageClass)
requestedBlockWidth - About how wide and tall you wish a block to be in pixels.public void process(T input, GrayU8 output)
process in interface InputToBinary<T extends ImageGray<T>>input - Input imageoutput - Output binary imageprotected void computeStatistics(T input, int innerWidth, int innerHeight)
protected abstract void computeBlockStatistics(int x0,
int y0,
int width,
int height,
int indexStats,
T input)
x0 - lower bound pixel value of block, x-axisy0 - upper bound pixel value of block, y-axiswidth - Block's widthheight - Block's heightindexStats - array index of statistics image pixelinput - Input imageprotected abstract void thresholdBlock(int blockX0,
int blockY0,
T input,
GrayU8 output)
blockX0 - Block x-coordinateblockY0 - Block y-coordinateinput - Input imageoutput - Output imagepublic boolean isThresholdFromLocalBlocks()
public void setThresholdFromLocalBlocks(boolean thresholdFromLocalBlocks)
public ImageType<T> getInputType()
getInputType in interface InputToBinary<T extends ImageGray<T>>