getHistogramVertical method

List<int> getHistogramVertical()

Returns the vertical histogram of the matrix.

The histogram represents the number of true (or inked) cells in each row of the matrix. The result is a list where each index corresponds to a row, and the value at that index represents the count of true values in that row.

Implementation

List<int> getHistogramVertical() {
  final List<int> histogram = List.filled(rows, 0);
  for (int y = 0; y < rows; y++) {
    for (int x = 0; x < cols; x++) {
      if (cellGet(x, y)) {
        histogram[y]++;
      }
    }
  }
  return histogram;
}