Extraction of image pixels and light and dark

Lack of rules for converting images to notes

PImage img;
PImage img2;

void setup() {
size(1008, 1000);
img = loadImage(“b.jpg”);
img2 = loadImage(“a.jpg”);
imageMode(CENTER);
noStroke();
background(255);
}

void draw() {

int i = 0;
while (i <= 25) {
drawPoint();
i = i +1;
}
}

void drawPoint() {

int x = int(random(img.width));
int y = int(random(img.height));
color pix = img.get(x,y);

float value = brightness (pix);
int i = round(map(value,0,255,0,700*700-1));
color c2 = img.pixels[i];

fill(c2,100);
rect(x,y,random(200,300),random(200,300));

saveFrame(“frames/###.png”);
}

Leave a Reply