The channels count can trivially be computed with popcount().
Attach a file by drag & drop or click to upload