#include #include "cv.h" #include "cxcore.h" #include "highgui.h" #pragma comment(lib,"cv.lib") #pragma comment(lib,"cxcore.lib") #pragma comment(lib,"highgui.lib") void KidoUp(unsigned char *out, unsigned char *in, int inHeight, int inWidth, int inChannel, double rate); int main(){ IplImage *in, *out; int i,j; in = cvLoadImage("./image640.bmp", 0); out = cvCreateImage(cvSize(in->width, in->height), in->depth, in->nChannels); KidoUp((unsigned char*)out->imageData, (unsigned char*)in->imageData, in->height, in->width, in->nChannels, 0.5); cvNamedWindow("in", 1); cvShowImage("in", in); cvNamedWindow("out", 1); cvShowImage("out", out); cvWaitKey(-1); cvDestroyWindow("in"); cvDestroyWindow("out"); cvReleaseImage( &in ); cvReleaseImage( &out ); return 0; } 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; } } }