globalThreshold static method
Otsu-style two-peak estimate over a 32-bucket histogram.
Implementation
static int globalThreshold(UGrayImage image) {
final Int32List buckets = Int32List(32);
final int step = image.height > 64 ? image.height ~/ 32 : 1;
for (int y = 0; y < image.height; y += step) {
final int rowStart = y * image.stride;
for (int x = 0; x < image.width; x++) {
buckets[image.data[rowStart + x] >> 3]++;
}
}
return _estimate(buckets) << 3;
}