def toWidthHeight(anchor):
    """Transforms an anchor in [x0,y0,x1,y1] format to [w,h,x,y]
    Where [w,h,x,y] stands for width, height, center x coord, center y coordinate
    """
    # Since in an anchor [x0,y0,x1,y1] we are represesnting not corner coordinates but
    # coordinates of pixels that compose the corner, actual widths go across the pixels
    # themselves, adding one to the total widths and heights of the regions covered by the
    # pixels themseles.
    width = anchor[2] - anchor[0] + 1
    height = anchor[3] - anchor[1] + 1

    x = .5 * (anchor[0] + anchor[2] + 1)
    y = .5 * (anchor[1] + anchor[3] + 1)

    return [width, height, x, y]