def bc(col, width):
    """Mirror the column coordinate at the borders of the image; width must be a defined variable in the calling function containing the image width"""
    if col < 0:
        return -col
    elif col >= width:
        return width - col + width - 2
    return col
