toList3D method
Returns a 3D list of the mat, only for multi-channel mats. The list is ordered as colchannels.
Example:
final mat = Mat.fromList(3, 3, MatType.CV_8UC1, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
final list = mat.toList3D();
print(list); // [[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]
Implementation
List<List<List<num>>> toList3D() {
cvAssert(channels >= 2, "toList3D() only for channels >= 2, but this.channels=$channels");
final rows = this.rows, cols = this.cols;
return List.generate(rows, (r) => List.generate(cols, (c) => atPixel(r, c)));
}