Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Growing elements

$
0
0
Hello,
I'm working on the installation with shadows, but my practical skills in coding are not that good to bring my project to life.. I really need your help guys.
Basically, what I need is somehow on a border, where black pixels change to white and another way round, suppose to appear a growing element (I draw it in Flash, so it has a quick time format). 
For a base I've taken a code from a library called BrightnessTresholding, however, the thing growths everywhere at the place of white pixels.

Thanks a lot!

P.S. This is what I've got so far:

import processing.video.*;

color black = color(0);
color white = color(255);
int numPixels;
Capture video;
Movie myMovie;

void setup() {
  size(640, 480); // Change size to 320 x 240 if too slow at 640 x 480
  strokeWeight(5);
  // Uses the default video input, see the reference if this causes an error
  video = new Capture(this, width, height, 24);
  numPixels = video.width * video.height;
  noCursor();
  smooth();
  
  myMovie = new Movie(this, "growingt.mov");
}

void draw() {
  
  background(255);
  if (video.available()) {
    
    video.read();
    video.loadPixels();
    int threshold = 127; // Set the threshold value
    float pixelBrightness; // Declare variable to store a pixel's color
    // Turn each pixel in the video frame black or white depending on its brightness
    
    for (int y = 0; y < video.height; y = y + 10)
    {
      for (int x = 0; x < video.width; x = x + 10){
         
        int location = x+(y*video.width);
        
        pixelBrightness = brightness(video.pixels[location]);
        
        if (pixelBrightness > 127) { // If the pixel is brighter than the
        
          // any visualisations go here
          image(myMovie, random(x-5, x+5), random(y-5, y+5 ));
         // strokeWeight(.5);
         // ellipse( random(x-5, x+5), random(y-5, y+5 ), 2, 2);
          
        }  
      }
    }
    
   
  }
}

Viewing all articles
Browse latest Browse all 1768

Trending Articles