画像処理入門 > 初級編 > 色反転

色反転


色反転
白黒反転するプログラムです。
サンプルは8bitのみ対応しています。

サンプルプログラム
プログラムはこちら void nega(unsigned char *out, unsigned char *in, int inHeight, int inWidth, int inChannel){ int i, j; int index; 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; // ネガポジ反転 out[index] = 255 - in[index]; } } }