Package boofcv.alg.filter.binary
Class ThresholdBlockOtsu
java.lang.Object
boofcv.alg.filter.binary.ThresholdBlockOtsu
- All Implemented Interfaces:
ThresholdBlock.BlockProcessor<GrayU8,InterleavedS32>
public class ThresholdBlockOtsu
extends Object
implements ThresholdBlock.BlockProcessor<GrayU8,InterleavedS32>
Block Otsu threshold implementation based on
ThresholdBlock. 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected intprotected boolean -
Constructor Summary
ConstructorsConstructorDescriptionThresholdBlockOtsu(boolean otsu2, double tuning, double scale, boolean down) Configures the detector -
Method Summary
Modifier and TypeMethodDescriptionvoidcomputeBlockStatistics(int x0, int y0, int width, int height, int indexStats, GrayU8 input, InterleavedS32 stats) Computes the min-max value inside a blockcopy()Creates a copy.voidinit(int blockWidth, int blockHeight, boolean thresholdFromLocalBlocks) voidthresholdBlock(int blockX0, int blockY0, GrayU8 input, InterleavedS32 stats, GrayU8 output) Thresholds all the pixels inside the specified block
-
Field Details
-
blockWidth
protected int blockWidth -
blockHeight
protected int blockHeight -
thresholdFromLocalBlocks
protected boolean thresholdFromLocalBlocks
-
-
Constructor Details
-
ThresholdBlockOtsu
public ThresholdBlockOtsu(boolean otsu2, double tuning, double scale, boolean down) Configures the detector- Parameters:
tuning- Tuning parameter. 0 = standard Otsu. Greater than 0 will penalize zero texture.
-
-
Method Details
-
createStats
- Specified by:
createStatsin interfaceThresholdBlock.BlockProcessor<GrayU8,InterleavedS32>
-
init
public void init(int blockWidth, int blockHeight, boolean thresholdFromLocalBlocks) - Specified by:
initin interfaceThresholdBlock.BlockProcessor<GrayU8,InterleavedS32>
-
computeBlockStatistics
public void computeBlockStatistics(int x0, int y0, int width, int height, int indexStats, GrayU8 input, InterleavedS32 stats) Description copied from interface:ThresholdBlock.BlockProcessorComputes the min-max value inside a block- Specified by:
computeBlockStatisticsin interfaceThresholdBlock.BlockProcessor<GrayU8,InterleavedS32> - Parameters:
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 image
-
thresholdBlock
public void thresholdBlock(int blockX0, int blockY0, GrayU8 input, InterleavedS32 stats, GrayU8 output) Description copied from interface:ThresholdBlock.BlockProcessorThresholds all the pixels inside the specified block- Specified by:
thresholdBlockin interfaceThresholdBlock.BlockProcessor<GrayU8,InterleavedS32> - Parameters:
blockX0- Block x-coordinateblockY0- Block y-coordinateinput- Input imageoutput- Output image
-
copy
Description copied from interface:ThresholdBlock.BlockProcessorCreates a copy. For concurrent code- Specified by:
copyin interfaceThresholdBlock.BlockProcessor<GrayU8,InterleavedS32>
-