def calculate_transformation_invariance(target_seg_image, projected_seg_image):
    """
    Calculates the transformation invariance scores between target and projected seg images.
    We calculate all non-black pixels and compare them.

    :param target_seg_image:
    :param projected_seg_image:
    :return: target_pixels, proj_pixels, pixel_ratio
    """
    gt_pixels = (target_seg_image != 0).sum() // 3
    proj_pixels = (projected_seg_image != 0).sum() // 3
    if proj_pixels < gt_pixels:
        identical_pixels = 1.0 * proj_pixels / gt_pixels
    else:
        identical_pixels = 1.0 * gt_pixels / proj_pixels

    return gt_pixels.cpu().numpy().item(),\
           proj_pixels.cpu().numpy().item(),\
           identical_pixels.cpu().numpy().item()