public class ThresholdBlockOtsu extends ThresholdBlockCommon<GrayU8,InterleavedS32>
ThresholdBlockCommon. 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.
blockHeight, blockWidth, requestedBlockWidth, stats, thresholdFromLocalBlocks| Constructor and Description |
|---|
ThresholdBlockOtsu(boolean otsu2,
ConfigLength requestedBlockWidth,
double tuning,
double scale,
boolean down,
boolean thresholdFromLocalBlocks)
Configures the detector
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
computeBlockStatistics(int x0,
int y0,
int width,
int height,
int indexStats,
GrayU8 input)
Computes the min-max value inside a block
|
protected void |
computeStatistics(GrayU8 input,
int innerWidth,
int innerHeight)
Computes the min-max value for each block in the image
|
protected void |
thresholdBlock(int blockX0,
int blockY0,
GrayU8 input,
GrayU8 output)
Thresholds all the pixels inside the specified block
|
getInputType, isThresholdFromLocalBlocks, process, setThresholdFromLocalBlockspublic ThresholdBlockOtsu(boolean otsu2,
ConfigLength requestedBlockWidth,
double tuning,
double scale,
boolean down,
boolean thresholdFromLocalBlocks)
requestedBlockWidth - About how wide and tall you wish a block to be in pixels.tuning - Tuning parameter. 0 = standard Otsu. Greater than 0 will penalize zero texture.protected void computeStatistics(GrayU8 input, int innerWidth, int innerHeight)
ThresholdBlockCommoncomputeStatistics in class ThresholdBlockCommon<GrayU8,InterleavedS32>protected void computeBlockStatistics(int x0,
int y0,
int width,
int height,
int indexStats,
GrayU8 input)
ThresholdBlockCommoncomputeBlockStatistics in class ThresholdBlockCommon<GrayU8,InterleavedS32>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 void thresholdBlock(int blockX0,
int blockY0,
GrayU8 input,
GrayU8 output)
ThresholdBlockCommonthresholdBlock in class ThresholdBlockCommon<GrayU8,InterleavedS32>blockX0 - Block x-coordinateblockY0 - Block y-coordinateinput - Input imageoutput - Output image