bool imageSubtract(IplImage* src, IplImage* dst)
{
int row = 0;//行
int col = 0;//列
uchar* pSrcData = NULL;
uchar* pDstData = NULL;
int stepSrc = 0;
int stepDst = 0;
if (!src || !dst)
{
return 0;
}
if ((src->height != dst->height) && (src->width != dst->width))
{
return 0;
}
pSrcData = (uchar *)src->imageData;
stepSrc = src->widthStep / sizeof(uchar);
pDstData = (uchar *)src->imageData;
stepDst = dst->widthStep / sizeof(uchar);
for (row = 0;row <src->height;row++)
{
for (col = 0;col<src->width;col++)
{
pDstData[row*stepDst + col] = abs(pSrcData[row*stepSrc + col] - pDstData[row*stepDst + col]);
}
}
return 1;
}