Skip to content

Instantly share code, notes, and snippets.

@hG3n
Created September 1, 2015 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hG3n/bbb4e45bbd836b2f7f9c to your computer and use it in GitHub Desktop.
Save hG3n/bbb4e45bbd836b2f7f9c to your computer and use it in GitHub Desktop.
two little functions converting either 2d into 1d or 1d into 2d coordinates
cv::Point index2Coord(int index)
{
int x = index % width;
int y = index / width;
return cv::Point(x,y);
}
int coord2Index(int x, int y)
{
return x + width*y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment