画像処理入門 > 初級編 > 輝度n倍

輝度n倍


輝度n倍
輝度をn倍するプログラムです。
減らすことも可能です。

サンプルプログラム
プログラムはこちら void KidoUp(unsigned char *out, unsigned char *in, int inHeight, int inWidth, int inChannel, double rate){ int i, j; int index; double tmp; int widthStep; widthStep = inWidth * inChannel; if(widthStep % 4 != 0){ widthStep = widthStep + 4 - widthStep % 4; } for(i = 0; i < inHeight; ++i){ for(j = 0; j < inWidth; ++j){ index = i * widthStep + j; tmp = (double)in[index] * rate; // 255を超えていたら255にする if(tmp > 255){ tmp = 255; } out[index] = tmp; } } }