Processing 画像処理 グレースケール proce55ing

Processingにはfilter()関数があって、filter(GRAY)とすればグレースケール画像を作ることができますが、それをつかわずに自作してみました。

グレースケールの方法はいろいろあって、RGBの平均をとったり、YCrCbに変換してYを使うなどがあるけど、今回は平均をとった。1つできれば全部できるからOK。

source code:

colorMode(RGB, 256);

int w = 350;//width of image
int h = 280;//height

size(w, h);
PImage img = loadImage("cold_penguin.jpg");
//filter(GRAY);

loadPixels();
println(pixels[20]);
println(blue(pixels[20]) );
println("\n");
println(img.pixels[20]);
println(blue(img.pixels[20]) );

for(int i=0; i

f:id:peroon:20071029195125j:image

f:id:peroon:20071029195153j:image