很简单,创建函数的步骤在以前的分享里,下面分享图片反色的函数实现:
void CImageProcessing_2View::InvertImg(IplImage cImg, IplImage iImg)
{
uchar data= (uchar )cImg->imageData;//show color
int wp = cImg->widthStep;
uchar *data1 = (uchar *)iImg->imageData;//show invert
int wp1 = iImg->widthStep;
for(int i = 0; i < cImg->height; i++)
{
for(int j = 0; j < cImg->width;j++)
{
data1[i * wp1 + 3 * j] = 255 - data[i * wp + 3 * j];
data1[i * wp1 + 3 * j + 1] = 255 - data[i * wp + 3 * j + 1];
data1[i * wp1 + 3 * j + 2] = 255 - data[i * wp + 3 * j + 2];
}
}
}