let img;
function preload() {
img = loadImage('https://i.loli.net/2018/10/19/5bc9db906f615.jpg')
}
function setup() {
createCanvas(img.width, img.height)
img.loadPixels();
for (let x = 0; x < img.width; x++) {
for (let y = 0; y < img.height; y++) {
let index = (x + y * img.width) * 4;
let c = img.pixels[index];
let b = brightness(c) // 获取亮度
if (b > 95) { // 这样做问题还有很多
img.set(x, y, color(0, 0))
}
}
}
img.updatePixels()
background(img)
}