def mask_area(mask):
    """Utility to calculate the area of a mask."""
    count = 0
    m_raveled = mask.ravel()
    for i in range(mask.size):
        if m_raveled[i] != 0:
            count += 1
    return count