, IPP (. photo_tom) , ( ):
uchar *iplImagePtr = (uchar *) iplImage->imageData;
uchar buf;
size_t limit = height * width;
for (size_t y = 0; y < limit; ++y) {
std::swap(iplImagePtr[y * 3], iplImagePtr[y * 3 + 2]);
}
, , , " !" , , , , , . iplImagePtr . ; y , "count from 0 to N-1", .
, , , (?). , ...
PS If you really compare this, I would also like to see how well the following works:
uchar *iplImagePtr = (uchar *) iplImage->imageData;
uchar buf;
size_t limit = height * width;
for (size_t y = 0; y < limit; ++y) {
uchar *pixel = iplImagePtr + y * 3;
std::swap(pix[0], pix[2]);
}
Again, it is pixeldefined in the cycle in order to limit its scope and prevent the optimizer from thinking about the dependence on the cycle to the cycle. If the compiler increments and decrements the stack pointer every time through the loop to “create” and “destroy” pixel, well, that’s stupid, and I apologize for wasting your time.
source
share