Пример #1
0
def write_six_img_grid_w_embedded_names(
    rgb_img: np.ndarray,
    pred: np.ndarray,
    label_img: np.ndarray,
    id_to_class_name_map: Mapping[int,str],
    save_fpath: str
) -> None:
    """
    Create a 6-image tile grid with the following structure:
    ------------------------------------------------------------
    RGB Image | Blended RGB+GT Label Map   | GT Label Map
    ------------------------------------------------------------
    RGB Image | Blended RGB+Pred Label Map | Predicted Label Map
    ------------------------------------------------------------
    We embed classnames directly into the predicted and ground
    truth label maps, instead of using a colorbar.

    Args:
        rgb_img: 
        pred: predicted label map
        label_img
        id_to_class_name_map
        save_fpath
    """
    assert label_img.ndim == 2
    assert pred.ndim == 2
    assert rgb_img.ndim == 3
    label_hgrid = form_mask_triple_embedded_classnames(
        rgb_img,
        label_img,
        id_to_class_name_map,
        save_fpath='dummy.jpg',
        save_to_disk=False
    )
    pred_hgrid = form_mask_triple_embedded_classnames(
        rgb_img,
        pred,
        id_to_class_name_map,
        save_fpath='dummy.jpg',
        save_to_disk=False
    )
    vstack_img = form_vstacked_imgs(
        img_list=[label_hgrid,pred_hgrid],
        vstack_save_fpath=save_fpath,
        save_to_disk=True
    )
Пример #2
0
def form_mask_triple_vertical(rgb_img: np.ndarray,
                              label_img: np.ndarray,
                              save_fpath: str,
                              save_to_disk: bool = False) -> np.ndarray:
    """
		Args:
		-	rgb_img: 
		-	label_img: 
		-	save_fpath
		-	save_to_disk

		Returns:
		-	Array, representing 3 horizontally concatenated images: from left-to-right, they are
				RGB, RGB+Semantic Masks, Semantic Masks 
	"""
    rgb_with_mask = convert_instance_img_to_mask_img(label_img, rgb_img.copy())
    mask_img = convert_instance_img_to_mask_img(label_img, img_rgb=None)
    return form_vstacked_imgs([rgb_img, rgb_with_mask, mask_img], save_fpath,
                              save_to_disk)
Пример #3
0
def test_form_vstacked_imgs_two():
	"""
	Vertically stack two 2x2 RGB images into a single 2x4 RGB image.
	"""
	vstack_save_fpath = 'vtmp.png'

	img1 = np.zeros((2,2,3), dtype=np.uint8)
	img1[0,0,:] = [255,0,1]

	img2 = np.zeros((2,2,3), dtype=np.uint8)
	img2[1,1,:] = [5,10,15]

	img_list = [img1, img2]

	vstack_img = form_vstacked_imgs(img_list, vstack_save_fpath, save_to_disk=False)

	gt_vstack_img = np.zeros((4,2,3), dtype=np.uint8)
	gt_vstack_img[0,0,:] = [255,0,1]
	gt_vstack_img[3,1,:] = [5,10,15]

	assert np.allclose(vstack_img, gt_vstack_img)