Sometimes you want to get a pixel of an image by referring to it as coordinates (x,y). The following functions return a relative position of a pixel that has to be added to the pointer of the image data:
long int XYToIndex(int x,int y)
{
return( (long int)x * (long int)channels +
(long int)y * (long int)rowstride);
}
See section
sec.filter-function for a description of
channels
and rowstride
.
Example of usage:
*(dest + XYToIndex (x, y)) =
*(src + XYToIndex (width - x, height - y));