// May be faster using pixel array directly
function f1()
{
//imgMask.loadPixels();
for (let x = 0; x < imgMask.width; x += 1)
{
for (let y = 0; y < imgMask.height; y += 1)
{
let c = imgMask.get(x, y);
let br = brightness(c); // 0 to 100 See color reference
//let alph = alpha(c);
//print(alph); // Confirmed that alpha was 255 by default.
if (br==100)
cm = color(0, 0);
else
cm = color(0, 255);
imgMask.set(x, y, cm);
}
}
imgMask.updatePixels();
}
I also got it working directly with the imgMask.pixels array and will leave that for the adventurous.