def convert_hsvpatches2rgb(patches): (amount, h, w, c) = patches.shape color_patches = np.full([amount, h, w, c], -1) for i in range(amount): color_patches[i] = hsv_to_rgb(patches[i]) * 255 return color_patches
def binarize_matrix(img_train_ref, label_dict): # Create binarized matrix w = img_train_ref.shape[0] h = img_train_ref.shape[1] # c = img_train_ref.shape[2] # binary_img_train_ref = np.zeros((1,w,h)) binary_img_train_ref = np.full((w, h), -1, dtype=np.uint8) for i in range(w): for j in range(h): r = img_train_ref[i][j][0] g = img_train_ref[i][j][1] b = img_train_ref[i][j][2] rgb = (r, g, b) rgb_key = str(rgb) binary_img_train_ref[i][j] = label_dict[rgb_key] return binary_img_train_ref