def rescale_center_xy(obj, config):
    """
    obj:     dictionary containing xmin, xmax, ymin, ymax
    config : dictionary containing IMAGE_W, GRID_W, IMAGE_H and GRID_H
    """

    center_x = .5 * (obj['xmin'] + obj['xmax'])
    center_x = center_x / (float(config['image_w']) / config['grid_w'])

    center_y = .5 * (obj['ymin'] + obj['ymax'])
    center_y = center_y / (float(config['image_h']) / config['grid_h'])

    return center_x, center_y