Gabriella Levine

ongoing and past work

ICM midterm

Not what I was going for at all, but below are images from my video capture. Here is the code and the rest of the applet.
Here are some shots:

It’s a stable background, when you move about, you wipe away the background with a video of you, that fades away over time.

What I thought I wanted to work on is a fiery background with you as the water blob in the foreground. or something – or at least a manipulatable background.

For the final…

Here is the code:

float angle = 0;
import processing.video.*;
import blobDetection.*;
float col=random(0,255);
Capture cam;
Shape [] myShapes = new Shape[100];
//Bauble[] baubles;
BlobDetection theBlobDetection;
PImage img;
PImage fireIMG;
boolean newFrame=false;
EdgeVertex eA,eB;
Blob b;
int radius;

int blurVar;
int blurChanger=5;

PImage myImage;
PImage buffer;

void setup()
{
// Size of applet
size(640, 480, P3D);
// Capture

cam = new Capture(this, width, height, 15);

buffer = createImage(cam.width, cam.height, ARGB);
myImage = loadImage(“drops.jpg”);
fireIMG = loadImage(“firephoto10.JPG”);

// BlobDetection
// img which will be sent to detection (a smaller copy of the cam frame);
img = new PImage(80,60);

theBlobDetection = new BlobDetection(img.width, img.height);
theBlobDetection.setPosDiscrimination(true);
theBlobDetection.setThreshold(0.2f); // will detect bright areas whose luminosity > 0.2f;

if (eA !=null && eB !=null) {
for (int i = 0;i myShapes[0] = new Shape(eA.x/10+i/10, eB.y/10+i/10, 10,random(100,255));
}
}
}

void captureEvent(Capture cam)
{
cam.read();
newFrame = true;
}

void draw()
{

//image(myImage, 0,0,width, height);
image(fireIMG, 0,0,width,height);

blurImg();

if(newFrame) {
//background(0,0,0,100);
newFrame=false;

img.copy(cam, 0, 0, cam.width, cam.height,
0, 0, img.width, img.height);

fastblur(img, 2);
theBlobDetection.computeBlobs(img.pixels);
drawBlobsAndEdges(true,true);
camBlur();
}
//drawShape();
}

void blurImg()
{

//blurVar = 2;
//blurVar=blurVar+blurChanger;
//if( blurVar>=5 || blurVar<=0)
//{blurChanger*=-1;
//}
//myImage.filter(BLUR,1);
//myImage.filter(DILATE);
}

void fastblur(PImage img,int radius)
{
if (radius<1) {
return;
}
int w=img.width;
int h=img.height;
int wm=w-1;
int hm=h-1;
int wh=w*h;
int div=radius+radius+1;
int r[]=new int[wh];
int g[]=new int[wh];
int b[]=new int[wh];
int rsum,gsum,bsum,x,y,i,p,p1,p2,yp,yi,yw;
int vmin[] = new int[max(w,h)];
int vmax[] = new int[max(w,h)];
int[] pix=img.pixels;
int dv[]=new int[256*div];
for (i=0;i<256*div;i++) {
dv[i]=(i/div);
}

yw=yi=0;

for (y=0;y rsum=gsum=bsum=0;
for(i=-radius;i<=radius;i++) {
p=pix[yi+min(wm,max(i,0))];
rsum+=(p & 0xff0000)>>16;
gsum+=(p & 0x00ff00)>>8;
bsum+= p & 0x0000ff;
}
for (x=0;x

r[yi]=dv[rsum];
g[yi]=dv[gsum];
b[yi]=dv[bsum];

if(y==0) {
vmin[x]=min(x+radius+1,wm);
vmax[x]=max(x-radius,0);
}
p1=pix[yw+vmin[x]];
p2=pix[yw+vmax[x]];

rsum+=((p1 & 0xff0000)-(p2 & 0xff0000))>>16;
gsum+=((p1 & 0x00ff00)-(p2 & 0x00ff00))>>8;
bsum+= (p1 & 0x0000ff)-(p2 & 0x0000ff);
yi++;
}
yw+=w;
}

for (x=0;x rsum=gsum=bsum=0;
yp=-radius*w;
for(i=-radius;i<=radius;i++) {
yi=max(0,yp)+x;
rsum+=r[yi];
gsum+=g[yi];
bsum+=b[yi];
yp+=w;
}
yi=x;
for (y=0;y pix[yi]=0xff000000 | (dv[rsum]<<16) | (dv[gsum]<<8) | dv[bsum];
if(x==0) {
vmin[y]=min(y+radius+1,hm)*w;
vmax[y]=max(y-radius,0)*w;
}
p1=x+vmin[y];
p2=x+vmax[y];

rsum+=r[p1]-r[p2];
gsum+=g[p1]-g[p2];
bsum+=b[p1]-b[p2];

yi+=w;
}
}
}

void drawBlobsAndEdges(boolean drawBlobs, boolean drawEdges)
{
noFill();

for (int n=0 ; n {
b=theBlobDetection.getBlob(n);
if (b!=null)
{
// Edges
if (drawEdges)
{
strokeWeight(3);
stroke(0,255,0);
for (int m=0;m {
eA = b.getEdgeVertexA(m);
eB = b.getEdgeVertexB(m);
if (eA !=null && eB !=null)
/* line(
eA.x*width, eA.y*height,
eB.x*width, eB.y*height

);*/
{
drawRect();

//drawBaubles(eA.x*width, eA.y*height);
}
}
}
}
}
}

void camBlur() {

cam.loadPixels();

buffer.loadPixels();

for (int x = 0; x < cam.width; x++)
{
for (int y = 0; y < cam.height; y++)
{
int location = y * cam.width + x;

float r = red (cam.pixels[location]);
float g = green (cam.pixels[location]);
float b = blue (cam.pixels[location]);
if (eA !=null && eB !=null) {
float distance = dist(x,y, eA.x*width-100, eB.y*height-100);//distance here - edge vertex
//println(distance);
float colorfactor = map (distance, 0,170, 5,1);

if (colorfactor < 1)
{
colorfactor = 1;
}

if (distance < 200){//|| (distance >300&&distance<400)) {
color c = color(r * colorfactor, g*colorfactor, b*colorfactor*2, 200);

buffer.pixels[location] = c;

// if(distance<400)
//
// {tint(0,0,255,50);
// image(myImage,0,0,width,height);
//// myImage=loadImage("drops.jpg");
//// myImage.loadPixels();
//
// }
//makeTurbulence(mouseX, mouseY);
}

else

{
float rb = red (buffer.pixels[location]);
float gb = green (buffer.pixels[location]);
float bb = blue (buffer.pixels[location]);
float ab = alpha (buffer.pixels[location]);

float amod = ab - 4;

if (amod < 0) {
amod = 0;
}
//float rbMod = 1;
//rb=rb+rbMod;
color c = color(rb*2, gb, bb, amod);
buffer.pixels[location] = c;
}
}
}
}

buffer.updatePixels();
//buffer.filter(BLUR,10);
buffer.filter(ERODE);
//buffer.filter(POSTERIZE,100);
// buffer.filter(ERODE);
tint(255,255,255,255);
image(buffer,0,0);

}

//FLIP THE IMAGE
//make the rects move
//put in dropp effect etc
void drawRect()
{
float xx = eA.x*width+random(-2,2);
float yy = eB.y*height+random(-2,2);
noStroke();

// fill(0,0,0,100);
tint(255,255,255,100);

image(myImage,xx,yy, 40,40); //HOW DTO MAKE IT ExpANd??? must i put a delay?

xx = xx+1;
yy=yy+1;
}

void drawShape(){
if (eA !=null && eB !=null) {
for (int j = 0; j myShapes[j] = new Shape(eA.x/2*width+j*random(-10,10), eB.y/2*height+j*random(-10,10), 10, random(100,255));

myShapes[j].drawShape();
myShapes[j].moveShape();
}
}
}
/*

void drawBaubles(float X, float Y){

noStroke();
fill(0);
float myx = random(0,X);
float myy = random(0,Y);
ellipse(myx, myy, 20,20);

}

void makeTurbulence(int cx, int cy) {
int r = radius * radius;
int left = cx < radius ? -cx + 1 : -radius;
int right = cx > (width – 1) – radius ? (width – 1) – cx : radius;
int top = cy < radius ? -cy + 1 : -radius;
int bottom = cy > (height – 1) – radius ? (height – 1) – cy : radius;

for (int x= right;x>left;x–){
int xsqr = x * x;

for (int y=bottom;y>top;y–){
if ((xsqr) + (y * y) < r)
heightMap[page ^ 1][cx + x][cy + y] += turbulenceMap[radius + x][radius + y];
// water.set(x,y,turbulenceMap[radius + x][radius + y]); //<<<-- kick do not update water here
}
}
}*/

class Shape
{
float xPos;
float yPos;
float rectSize;
float myColor;

Shape(float _xPos, float _yPos, float _rectSize, float _myColor){
xPos = _xPos;
yPos = _yPos;
rectSize = _rectSize;
myColor=_myColor;
}

void drawShape()
{noStroke();
fill(255,255,255, 150);
ellipse(xPos, yPos, rectSize*2, rectSize*2);

}

void moveShape()
{
xPos = xPos-1;
yPos = yPos-1;
}
}

Leave a Reply