def union_boxes(box_a, box_b):
    """
    Merges two rectangles.
    Args:
        box_a  <tuple>  : First rectangle (x, y, w, h)
        box_b  <tuple>  : Second rectangle (x, y, w, h)

    Returns:
        merged_box  <tuple> : Merged rectangle (x, y, w, h)
    """

    ax1, ay1, aw, ah = box_a
    ax2, ay2 = ax1+aw-1, ay1+ah-1

    bx1, by1, bw, bh = box_b
    bx2, by2 = bx1+bw-1, by1+bh-1

    x1 = min(ax1, bx1)
    y1 = min(ay1, by1)
    x2 = max(ax2, bx2)
    y2 = max(ay2, by2)

    merged_box = [x1, y1, x2-x1+1, y2-y1+1]
    return merged_box