public abstract class ThresholdSquareBlockMinMax<T extends ImageSingleBand,I extends ImageInterleaved>
extends java.lang.Object
Applies a threshold to an image by computing the min and max values in a regular grid across the image. When thresholding all the pixels inside a box (grid element) the min max values is found in the surrounding 3x3 grid region. If the difference between min and max is ≤ textureThreshold then it will be marked as one, since it is considered a textureless region. Otherwise the pixel threshold is set to (min+max)/2.
This thresholding strategy is designed to quickly detect shapes with nearly uniform values both inside the image and along the image border, with locally variable intensity values. The image border is particularly problematic since there are no neighboring pixels outside the image from which to compute a local threshold. This is why if a region is considered textureless it is marked as 1.
The min-max values inside 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 were was inspired by a high level description found in AprilTags.
| Modifier and Type | Field and Description |
|---|---|
protected int |
blockHeight |
protected int |
blockWidth |
protected double |
minimumSpread |
protected I |
minmax |
protected int |
requestedBlockWidth |
| Constructor and Description |
|---|
ThresholdSquareBlockMinMax(double minimumSpread,
int requestedBlockWidth)
Configures the detector
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
computeMinMaxBlock(int x0,
int y0,
int width,
int height,
int indexMinMax,
T input)
Computes the min-max value inside a block
|
void |
process(T input,
ImageUInt8 output)
Converts the gray scale input image into a binary image
|
protected abstract void |
thresholdBlock(int blockX0,
int blockY0,
T input,
ImageUInt8 output)
Thresholds all the pixels inside the specified block
|
protected I extends ImageInterleaved minmax
protected double minimumSpread
protected int requestedBlockWidth
protected int blockWidth
protected int blockHeight
public ThresholdSquareBlockMinMax(double minimumSpread,
int requestedBlockWidth)
minimumSpread - If the difference between min max is less than or equal to this
value then it is considered textureless. Set to <= -1 to disable.requestedBlockWidth - About how wide and tall you wish a block to be in pixels.public void process(T input, ImageUInt8 output)
input - Input imageoutput - Output binary imageprotected abstract void thresholdBlock(int blockX0,
int blockY0,
T input,
ImageUInt8 output)
blockX0 - Block x-coordinateblockY0 - Block y-coordinateinput - Input imageoutput - Output imageprotected abstract void computeMinMaxBlock(int x0,
int y0,
int width,
int height,
int indexMinMax,
T input)
x0 - lower bound pixel value of block, x-axisy0 - upper bound pixel value of block, y-axiswidth - Block's widthheight - Block's heightindexMinMax - array index of min-max image pixelinput - Input image