Advertisement
xeromino

noiseFilter

Mar 7th, 2017
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. import com.hamoid.*;
  2.  
  3. VideoExport videoExport;
  4. PImage img;
  5. float nz;
  6.  
  7. void setup() {
  8.   size(500, 540);
  9.   img = loadImage("photo2.jpg");
  10.   videoExport = new VideoExport(this, "internetVideo.mp4");
  11.   videoExport.setFrameRate(30);
  12.   videoExport.startMovie();
  13.  
  14. }
  15.  
  16. void draw() {
  17.   filterStuff();
  18.   if (frameCount<600) videoExport.saveFrame();
  19.   if (frameCount>=600) videoExport.endMovie();
  20. }
  21.  
  22. void filterStuff() {
  23.   image(img, 0, 0);
  24.   colorMode(HSB);
  25.   loadPixels();
  26.   float nx = 0;
  27.   float ny = 0;
  28.   for (int x=0; x<width; x++) {
  29.     ny = 0;
  30.     for (int y=0; y<height; y++) {
  31.       float ns = noise(nx, ny, nz);
  32.       float h = hue(img.get(x, y));
  33.       float s = saturation(img.get(x, y));
  34.       float b = brightness(img.get(x, y));
  35.       if (ns > 0.5) pixels[y*width+x] = color(h, 255-s, b);
  36.       ny += 0.005;
  37.     }
  38.     nx += 0.005;
  39.   }
  40.   updatePixels();
  41.   nz += 0.007;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement