We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
HSBpixels (Read 519 times)
HSBpixels
Aug 14th, 2009, 5:31pm
 
Hi,

I want to pick up HSB colors from video pixels[] more faster.
So,i refer to "HsvSpace".  I converted my code process into "HsvSpace"'s process.
processing.org/learning/libraries/hsvspace.html

but,my code can't drow.

What's wrong with this code?
Can I ask your advice on something?


Code:

import processing.video.*;
Capture video;

PImage img01= createImage(640,480,ARGB);
int w=640;
int h=480;
color[] nowColor=new color[w*h];

float[] hsb = new float[3];

void setup(){
size(w,h);
colorMode(HSB,360,100,100);
video=new Capture(this,w,h);
}

void draw(){
background(0);
video.read();
video.loadPixels();
img01.loadPixels();

for(int i=0;i<width*height;i++){
//
int pixelColor = video.pixels[i];
int r = (pixelColor >> 16) & 0xff;
int g = (pixelColor >> 8) & 0xff;
int b = pixelColor & 0xff;

hsb = Color.RGBtoHSB(r, g, b, hsb);

float difHue=hsb[0];
float difSaturation=hsb[1];
float difBrightness=hsb[2];


if(difSaturation<45||difBrightness<20||0>difHue||360<difHue){
img01.pixels[i]=color(0,0,100);
}
else{
img01.pixels[i]=color(difHue,difSaturation+0,difBrightness+0);
}

nowColor[i]=video.pixels[i];
}

img01.updatePixels();
image(img01,0,0,640,480);
}


(sorry for my englisch)
Thanks.
Page Index Toggle Pages: 1