20 januari 2010

Real time video processing (2)

Here you separate light and dark and sort the pixels likewise. For Sarah and Hsien!
import processing.video.*;
Movie myMovie;

void setup() {
  size(200,150, P2D);
  myMovie = new Movie(this, "mymovie.mov");
  myMovie.loop();
}

void draw() {
  if(myMovie.available()) {
    myMovie.read();
  }
  image(myMovie, 0, 0);

  loadPixels();

  int[] p = {};
  for (int i = 0; i < width * height; i++) {
    color c1 = pixels[i];
    int br = int(brightness(c1));
    if (br > 50) {
      p = append(p, 1);
    }
  }
  
  for (int w = 0; w < width * height; w++) {
    if (w < p.length) {
      pixels[w] = color(255,255,255);
    } else {
      pixels[w] = color(0,0,0);
    }
  }
  updatePixels();
}

Geen opmerkingen:

Een reactie posten