...
Code Block | ||||
---|---|---|---|---|
| ||||
PImage myImage; PImage destImage; void setup() { size(200, 200); myImage = loadImage("EinBild.png"); destImage = createImage(width, height, RGB); } void draw() { myImage.loadPixels(); destImage.loadPixels(); for(int x=1; x<width; x++) { for(int y=0; y<height; y++) { int currLoc = x+y*width; color currColor = myImage.pixels[currLoc]; int prevLoc = (x-1)+y*width; color prevColor = myImage.pixels[prevLoc]; float difference = abs(brightness(currColor)-brightness(prevColor)); destImage.pixels[currLoc] = color(difference); } } destImage.updatePixels(); image(destImage, 0, 0); } |
Weitere Beispiele
Line Art
Code Block | ||||
---|---|---|---|---|
| ||||
PImage myImage;
void setup() {
size(1920, 1080);
myImage = loadImage("Gradient_3.png");
smooth();
}
void draw() {
myImage.loadPixels();
background(0);
// image(myImage,0,0);
int steps = mouseX + 4;
for (int x=0; x<width; x+=steps) {
for (int y=0; y<height; y+=steps) {
int loc = x+y*width;
float bright = brightness(myImage.pixels[loc]);
color c = myImage.pixels[loc];
pushMatrix();
translate(x, y);
rotate(radians((bright/255)*360));
stroke(c);
strokeWeight(2);
line((bright/255)*-50, 0, (bright/255)*50, 0);
popMatrix();
}
}
updatePixels();
} |
ASCII Art
Code Block | ||||
---|---|---|---|---|
| ||||
PImage myImage;
void setup() {
size(900, 900);
myImage = loadImage("Marilyn.jpg");
smooth();
}
void draw() {
myImage.loadPixels();
background(0);
// image(myImage,0,0);
int steps = mouseX+10;
for (int x=0; x<width; x+=steps) {
for (int y=0; y<height; y+=steps) {
int loc = x+y*width;
float bright = brightness(myImage.pixels[loc]);
color c = myImage.pixels[loc];
fill(c);
textSize(map(bright,0,255,0,50));
String ascii = Character.toString((char) int(bright));
text(ascii,x,y);
}
}
updatePixels();
} |
Aufgaben
- Lest und versteht Seite 270 – 272 (Convolution Filter) im Buch “Learning Processing” von Daniel Shiffman.
- Schaut euch die Beispiele zu Bildern unter Generative Gestaltung an.
- Erstellt ein Beispiel, welches euch das Histogramm eines Bildes visuell wieder gibt. (R,G,B,Brightness).
- Erstellt ein Beispiel, welches für bestimmte Helligkeitswerte einen Buchstaben zeichnet.
...