toBinaryMask method

Uint8List toBinaryMask({
  1. double threshold = 0.5,
})

Create a simple binary mask from confidence values.

Threshold: pixels with confidence > threshold become 255 (person)

Implementation

Uint8List toBinaryMask({double threshold = 0.5}) {
  final mask = Uint8List(length);
  final thresholdByte = (threshold * 255).round();

  for (int i = 0; i < length; i++) {
    mask[i] = this[i] > thresholdByte ? 255 : 0;
  }

  return mask;
}