Пример #1
0
def viewFlow(flow_array, dimx, dimy, to_8bit = False, filename = None, show = True):
    root = "..//data//output//testing_images"
    if to_8bit:
        flow_array = (flow_array * 255).astype(np.uint8)
    colormap = img2rgb(flow_array, dimx, dimy)
    im = Image.fromarray(colormap)
    if show:
        fig, ax = plt.subplots(1)
        ax.imshow(im)
    if filename is not None:
        im.save(os.path.join(root,filename), quality=100)
def viewFlow(flow_array, dimx, dimy):
    colormap = img2rgb(flow_array, dimx, dimy)
    im = Image.fromarray(colormap)
    fig, ax = plt.subplots(1)
    ax.imshow(im)
from Vector_Extractor import exr2flow, img2rgb

data_path = "F://Flying_monkeys_2_RGB//test"

file_names = sorted(os.listdir(data_path))
i = 0

visual = False

for file in file_names:
    if file.startswith("gt"):

        i = i + 1
        #img = np.load(os.path.join(data_path, file))
        flow = np.load(os.path.join(data_path, file))

        flow = np.reshape(flow, (192, 256, 2))
        #print(np.shape(flow))

        print(np.shape(flow))

        if visual:
            truth_colormap = img2rgb(flow, 256, 192)
            im = Image.fromarray(truth_colormap)
            fig, ax = plt.subplots(1)
            ax.imshow(im)

        np.save(os.path.join(data_path, file), flow)
        #if i > 10:
        #    break
        print(i)
        #print(I[75:76])


    lost_photons = sump - np.sum(example[:, :, 0])


    file_name_flow = Flow_base + str(32).zfill(2) + '.exr'
    # print(file_name)
    image_set = exr2flow(os.path.join(data_path,file_name_flow ), 240, 200)


    truth = image_set[0]
    example_set = (example, truth)

    if image_gen:
        truth_colormap = img2rgb(example_set[1] ,240, 200)
        im = Image.fromarray(truth_colormap)
        fig, ax = plt.subplots(1)
        ax.imshow(im)
    ex_file_name = 'ex_' + str(i)
    np.save(os.path.join(dataset_path, ex_file_name ), example_set)

    #print(sump)
    #print(lost_photons)
    #print()
    photons_list.append(sump)
    lost_photons_list.append(lost_photons)

print("median of lost photons", statistics.median(lost_photons_list))
print("median of photons", statistics.median(photons_list))
Пример #5
0
    if visualsave:
        points_Image[:, :, 0] = example[:, :, 1]
        points_Image[:, :, 1] = example[:, :, 3]
        points_Image[:, :, 2] = example[:, :, 5]
        pointsIMG = Image.fromarray(np.uint8(points_Image[:, :, 0] * 255 * 2))
        pointsIMG.save(os.path.join(info_path, str(ex) + 'R.png'))
        pointsIMG = Image.fromarray(np.uint8(points_Image[:, :, 1] * 255 * 2))
        pointsIMG.save(os.path.join(info_path, str(ex) + 'G.png'))
        pointsIMG = Image.fromarray(np.uint8(points_Image[:, :, 2] * 255 * 2))
        pointsIMG.save(os.path.join(info_path, str(ex) + 'B.png'))

    example_set = (example, truth)

    if image_gen:
        truth_colormap = img2rgb(example_set[1], 192, 256)
        im = Image.fromarray(truth_colormap)
        fig, ax = plt.subplots(1)
        ax.imshow(im)
    #ex_file_name = 'ex_' + str(i)
    #np.save(os.path.join(dataset_path, ex_file_name ), example_set)

    #print(sump)
    #print(lost_photons)
    #print()
    photons_list.append(sump)
    lost_photons_list.append(lost_photons)

    if ex < number_train:
        traindata_filename = "data_" + str(tr)
        traingt_filename = "gt_" + str(tr)