Does the mask-function behave differently from Processing to P5?

Hello @alignleft,

This was a challenge with p5.js but I got it sorted out.

See references to understand the difference:

In function setup():

  imgMask.filter(THRESHOLD, .5); 
  f1();
  img1.mask(imgMask); 

I had to set the alpha channel directly:

// 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.

:)