This is what I got so far, but it's seems that I've flipped it somehow. (see attached screenshot)
bool Navigation::worldToMap(double wx, double wy, unsigned int& mx, unsigned int& my) {
    float minX, minY;
    cv::Mat map = grid_.getMap(minX, minY);
    if (wx < minX || wy < minY)
      return false;
    mx = (int)((wx - minX) / grid_.getCellSize());
    my = (int)((wy - minY) / grid_.getCellSize());
    if (mx < map.cols && my < map.rows)
      return true;
    return false;
}
void Navigation::mapToWorld(int mx, int my, double& wx, double& wy) {
    // returns the center point of the cell
    float minX, minY;
    cv::Mat map = grid_.getMap(minX, minY);
    wx = minX + (mx + 0.5) * grid_.getCellSize();
    wy = minY + (my + 0.5) * grid_.getCellSize();
}