User Tools

Site Tools


cs276:hw_5_cjk

Homework 5

I edited the brightness tracking algorithm for my homework assignment. First, I changed the initial transparent yellow ellipse to a smaller transparent picture of my friend's cat. So now where ever the brightest pixel is in the camera field of view, this cat appears covering it (his name is Sargon just in case you were wondering). I also modified the algorithm so that according to the placement of the brightest pixel in the tint of the camera changes. If you were to take a flashlight and shine it from one end of the screen to the other, you would notice the color of the screen changing as the cat floats across the screen with the light.

Using the flashlight on my phone for the light source, I took these screenshots.


Here are a few screen shots of me testing the unedited other algorithms we were given:

Background subtraction

Brightness Thresholding

Frame Differencing


Code for my modified algorithm:

/* * Brightness Tracking * * modified by Corinne Konoza * October 23, 2014 * CS 276 HW 5 * Tracks the brightest pixel in a live video signal plus some * special modifications to make it more interesting. * */

import processing.video.*;

Capture video; PImage pic;

void setup(){

pic = loadImage("crazygoon.png");
tint(255, 126);
pic.resize(100,0);
size(640,480);
video = new Capture(this, width, height, 24);
noStroke();
smooth();
video.start();

}

void draw() {

if(video.available()){
  video.read();
  image(video,0,0,width,height);
  
  // The color of the video changes with mouse position
 // tint(mouseX, mouseY,255);
  
  int brightestX = 0;
  int brightestY = 0;
  float brightestValue = 0;
  
  video.loadPixels();
  int index = 0;
  for(int y = 0; y < video.height; y++){
    for(int x = 0; x < video.width; x++) {
      int pixelValue = video.pixels[index];
      float pixelBrightness = brightness(pixelValue);
      if(pixelBrightness > brightestValue){
        brightestValue = pixelBrightness;
        brightestY = y;
        brightestX = x;
      }
      index++;
    }
  }
  fill(255,204,0,128);
  
  /* A transparent image will appear where the brighest pixels are and
   * the color of the video will change according to the location of the 
   * brightest pixel.
   */
   
  tint(brightestX, brightestY, 255);
  image(pic, brightestX, brightestY);
}

}

cs276/hw_5_cjk.txt · Last modified: 2014/10/23 15:51 by ckonoza