Save Image?
in
Programming Questions
•
8 months ago
So I've spent all day trying to figure out how to save the results of the code below as an image.. I feel it's time to post a question and receive the probably obvious and simple answer.
The code is not mine, I forget who posted it and have no browser history to find out who it was. But I got it off this forum.
Anyway here it is..
- PImage img;
- void setup() {
- img = loadImage("image.jpg");
- size(img.width,img.height);
- }
- void draw() {
- background(255);
- loadPixels();
- for (int y = 0; y<height; y+=1 ) {
- for (int x = 0; x<width; x+=1) {
- int loc = x + y*img.width;
- float r = red (img.pixels[loc]);
- float g = green (img.pixels[loc]);
- float b = blue (img.pixels[loc]);
- float av = ((r+b+g)/1.0);
- pushMatrix();
- translate(x,y);
- stroke(r,g,b);
- if (r > 50 && r < 150) {
- line(0,0,(av-10)/1,0);}
- popMatrix();
- }
- }
- println("done");
- noLoop();
- }
So any ideas as to what code is needed to save the results?
Thanks,
Brod.
1