Do you want to limit the circles so they only cover black pixels, or do you only want to randomly place circles on black areas?
The former is hard. The latter is easy:
- PImage img = loadImage( "http://ecx.images-amazon.com/images/I/31oBZMlxIYL._SX342_.jpg" );
- void setup(){
- size( img.width, img.height );
- image(img, 0, 0);
- filter( THRESHOLD, 0.9);
- ellipseMode(CENTER);
- }
- void draw(){
- fill( random(255), random(255), random(255) );
- noStroke();
- int x = int(random(width));
- int y = int(random(height));
- if( get(x,y) == color(0) ){
- ellipse( x, y, 5, 5);
- }
- }