Processingにはfilter()関数があって、filter(GRAY)とすればグレースケール画像を作ることができますが、それをつかわずに自作してみました。
グレースケールの方法はいろいろあって、RGBの平均をとったり、YCrCbに変換してYを使うなどがあるけど、今回は平均をとった。1つできれば全部できるからOK。
source code:
colorMode(RGB, 256);
int w = 350;//width of image
int h = 280;//heightsize(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