(img_cumsum, bbox)
return ret
check a 2d voxel is contained by a box. used to filter empty
    anchors.
    Summed-area table algorithm:
    ==> W
    ------------------
    |      |         |
    |------A---------B
    |      |         |
    |      |         |
    |----- C---------D
    Iabcd = ID-IB-IC+IA
    Args:
        img_cumsum: [M, H, W](yx) cumsumed image.
        bbox: [N, 4](xyxy) bounding box,
check a 2d voxel is contained by a box. used to filter empty
    anchors.
    Summed-area table algorithm:
    ==> W
    ------------------
    |      |         |
    |------A---------B
    |      |         |
    |      |         |
    |----- C---------D
    Iabcd = ID-IB-IC+IA
    Args:
        img_cumsum: [M, H, W](yx) cumsumed image.
        bbox: [N, 4](xyxy) bounding box,
check a 2d voxel is contained by a box . used to filter empty anchors . Summed - area table algorithm : == > W ------------------ | | | | ------ A --------- B | | | | | | | ----- C --------- D Iabcd = ID - IB - IC + IA Args : img_cumsum : [ M H W ] ( yx ) cumsumed image . bbox : [ N 4 ] ( xyxy ) bounding box
def image_box_region_area(img_cumsum, bbox):
    """check a 2d voxel is contained by a box. used to filter empty
    anchors.
    Summed-area table algorithm:
    ==> W
    ------------------
    |      |         |
    |------A---------B
    |      |         |
    |      |         |
    |----- C---------D
    Iabcd = ID-IB-IC+IA
    Args:
        img_cumsum: [M, H, W](yx) cumsumed image.
        bbox: [N, 4](xyxy) bounding box, 
    """
    N = bbox.shape[0]
    M = img_cumsum.shape[0]
    ret = np.zeros([N, M], dtype=img_cumsum.dtype)
    ID = img_cumsum[:, bbox[:, 3], bbox[:, 2]]
    IA = img_cumsum[:, bbox[:, 1], bbox[:, 0]]
    IB = img_cumsum[:, bbox[:, 3], bbox[:, 0]]
    IC = img_cumsum[:, bbox[:, 1], bbox[:, 2]]
    ret = ID - IB - IC + IA
    return ret
def image_box_region_area ( img_cumsum , bbox ) : N = bbox . shape [ 0 ] M = img_cumsum . shape [ 0 ] ret = np . zeros ( [ N , M ] , dtype = img_cumsum . dtype ) ID = img_cumsum [ : , bbox [ : , 3 ] , bbox [ : , 2 ] ] IA = img_cumsum [ : , bbox [ : , 1 ] , bbox [ : , 0 ] ] IB = img_cumsum [ : , bbox [ : , 3 ] , bbox [ : , 0 ] ] IC = img_cumsum [ : , bbox [ : , 1 ] , bbox [ : , 2 ] ] ret = ID - IB - IC + IA return ret