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.