Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

カメラで取得したイメージのRGBをHSBに変換する

f:id:aa_debdeb:20160517002848j:plain
/**
* rgb to hsb for camera image
*
* @author aa_debdeb
* @date 2016/05/26
*/

import processing.video.*;

Capture camera;

void setup(){
  size(480, 360);
  camera = new Capture(this, width, height);
  camera.start();
}

void draw(){
  colorMode(RGB, 255);
  background(255);
  colorMode(HSB, 360, 100, 100);
  camera.loadPixels();
  for(int x = 0; x < width; x++){
    for(int y = 0; y < height; y++){
      color c = camera.pixels[y * width + x];
      stroke(hue(c), 100, 100);
      point(x, y);
    }
  }
}


void captureEvent(Capture camera){
  camera.read();
}