def get_patch(LF, cv, disp, by, bx): patch = dict() # compute actual coordinates y = by * data_config['SY'] x = bx * data_config['SX'] py = data_config['H'] px = data_config['W'] # extract data # (stack_h, stack_v) = lf_tools.epi_stacks( LF, y, x, py, px ) (stack_v, stack_h) = lf_tools.epi_stacks(LF, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) patch['stack_v'] = stack_v patch['stack_h'] = stack_h patch['cv'] = cv[y:y + py, x:x + px] if disp is not None: depth = disp[y:y + py, x:x + px] depth = np.minimum(data_config['dmax'], depth) depth = np.maximum(data_config['dmin'], depth) patch['depth'] = depth return patch
def get_patch( LF, by, bx, lf_scale ): patch = dict() # compute actual coordinates # if lf_scale == 's2': # y = by * hp.sy_s2 # x = bx * hp.sx_s2 # py = hp.H_s2 # px = hp.W_s2 # # if lf_scale == 's4': # y = by * hp.sy_HR # x = bx * hp.sx_HR # py = hp.H_s4 # px = hp.W_s4 y = by * hp.sy x = bx * hp.sx py = hp.H px = hp.W # extract data (stack_h, stack_v) = lf_tools.epi_stacks( LF, y, x, py, px ) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose( stack_h, (0, 2, 1, 3) ) patch[ 'stack_v' ] = stack_v patch[ 'stack_h' ] = stack_h return patch
def get_patch(LF_LR, by, bx): patch = dict() # compute actual coordinates y = by * data_config['SY'] x = bx * data_config['SX'] py = data_config['H'] px = data_config['W'] # extract data # (stack_h, stack_v) = lf_tools.epi_stacks( LF, y, x, py, px ) (stack_v, stack_h) = lf_tools.epi_stacks(LF_LR, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) patch['stack_v'] = stack_v patch['stack_h'] = stack_h patch['cv'] = np.zeros((data_config['H_HR'], data_config['W_HR'], 3)) return patch
def get_patch( LF_LR, by, bx ): patch = dict() # compute actual coordinates y = by * hp.sy x = bx * hp.sx py = hp.H px = hp.W # extract data # (stack_h, stack_v) = lf_tools.epi_stacks( LF, y, x, py, px ) (stack_v, stack_h) = lf_tools.epi_stacks( LF_LR, y, x, py, px ) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose( stack_h, (0, 2, 1, 3) ) patch[ 'stack_v' ] = stack_v patch[ 'stack_h' ] = stack_h patch['cv'] = np.zeros((hp.H_HR,hp.W_HR,hp.C) ) return patch
# write out one individual light field # block count cx = np.int32((LF.shape[3] - px) / sx) + 1 cy = np.int32((LF.shape[2] - py) / sy) + 1 for by in np.arange(0, cy): sys.stdout.write('.') sys.stdout.flush() for bx in np.arange(0, cx): x = bx * sx y = by * sx # extract data (stack_v, stack_h) = lf_tools.epi_stacks(LF, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) cv = cv_gt[y:y + py, x:x + px] #code.interact( local=locals() ) # write to respective HDF5 datasets dset_v.resize(index + 1, 4) dset_v[:, :, :, :, index] = stack_v dset_h.resize(index + 1, 4) dset_h[:, :, :, :, index] = stack_h dset_cv.resize(index + 1, 3)
cx_HR = np.int32((LF.shape[3] - px) / sx) + 1 cy_HR = np.int32((LF.shape[2] - py) / sy) + 1 for by in np.arange(0, cy_LR): sys.stdout.write('.') sys.stdout.flush() for bx in np.arange(0, cx_LR): x_LR = bx * sx_LR y_LR = by * sx_LR x = bx * sx y = by * sx # extract data (stack_v, stack_h) = lf_tools.epi_stacks(LF_LR, y_LR, x_LR, py_LR, px_LR) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) cv = cv_gt[y:y + py, x:x + px] # plt.imshow(cv) # plt.axis('off') # plt.show() # code.interact( local=locals() ) # write to respective HDF5 datasets dset_v.resize(index + 1, 4) dset_v[:, :, :, :, index] = stack_v dset_h.resize(index + 1, 4) dset_h[:, :, :, :, index] = stack_h
# write out one individual light field # block count cx = np.int32((LF.shape[3] - px) / sx) + 1 cy = np.int32((LF.shape[2] - py) / sy) + 1 for by in np.arange(0, cy): sys.stdout.write('.') sys.stdout.flush() for bx in np.arange(0, cx): x = bx * sx y = by * sx # extract data (stack_v, stack_h) = lf_tools.epi_stacks(LF, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) (diffuse_stack_v, diffuse_stack_h) = lf_tools.epi_stacks(LF_diffuse, y, x, py, px) diffuse_stack_h = np.transpose(diffuse_stack_h, (0, 2, 1, 3)) (specular_stack_v, specular_stack_h) = lf_tools.epi_stacks(LF_specular, y, x, py, px) specular_stack_h = np.transpose(specular_stack_h, (0, 2, 1, 3)) depth = disp_gt[y:y + py, x:x + px] cv = cv_gt[y:y + py, x:x + px] diffuse = cv_diffuse[y:y + py, x:x + px] specular = cv_specular[y:y + py, x:x + px]
# write out one individual light field # block count cx = np.int32((LF.shape[3] - px) / sx) + 1 cy = np.int32((LF.shape[2] - py) / sy) + 1 for by in np.arange(0, cy): sys.stdout.write('.') sys.stdout.flush() for bx in np.arange(0, cx): x = bx * sx y = by * sx # extract data (stack_v, stack_h) = lf_tools.epi_stacks(LF, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h = np.transpose(stack_h, (0, 2, 1, 3)) (stack_v_albedo, stack_h_albedo) = lf_tools.epi_stacks(LF_albedo, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h_albedo = np.transpose(stack_h_albedo, (0, 2, 1, 3)) (stack_v_sh, stack_h_sh) = lf_tools.epi_stacks(LF_sh, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h_sh = np.transpose(stack_h_sh, (0, 2, 1, 3)) (stack_v_specular, stack_h_specular) = lf_tools.epi_stacks(LF_specular, y, x, py, px) stack_h_specular = np.transpose(stack_h_specular, (0, 2, 1, 3))
# block count cx_HR = np.int32((LF_temp.shape[3] - px) / sx) + 1 cy_HR = np.int32((LF_temp.shape[2] - py) / sy) + 1 for by in np.arange(0, cy_HR): sys.stdout.write('.') sys.stdout.flush() for bx in np.arange(0, cx_HR): x = bx * sx y = by * sx # extract data (stack_h_HR, stack_v_HR) = lf_tools.epi_stacks(LF_temp, y, x, py, px) # make sure the direction of the view shift is the first spatial dimension stack_h_HR = np.transpose(stack_h_HR, (0, 2, 1, 3)) # write to respective HDF5 datasets # dset_v_HR.resize(index + 1, 4) # dset_v_HR[:, :, :, :, index] = stack_v_HR # # dset_h_HR.resize(index + 1, 4) # dset_h_HR[:, :, :, :, index] = stack_h_HR # next patch index = index + 1 elif folder == 'K_H_O': data_folders = os.listdir(data_source + folder + '/')
sys.stdout.flush() for bx in np.arange(0, cx_HR): x_LR_s2 = bx * sx_LR_s2 y_LR_s2 = by * sx_LR_s2 x_LR_s4 = bx * sx_LR_s4 y_LR_s4 = by * sx_LR_s4 x = bx * sx y = by * sx # extract data # scale 4 (stack_h_LR_s4, stack_v_LR_s4) = lf_tools.epi_stacks(LF_LR_s4, y_LR_s4, x_LR_s4, py_LR_s4, px_LR_s4) # make sure the direction of the view shift is the first spatial dimension stack_h_LR_s4 = np.transpose(stack_h_LR_s4, (0, 2, 1, 3)) # write to respective HDF5 datasets dset_v_LR_s4.resize(index + 1, 4) dset_v_LR_s4[:, :, :, :, index] = stack_v_LR_s4 dset_h_LR_s4.resize(index + 1, 4) dset_h_LR_s4[:, :, :, :, index] = stack_h_LR_s4 # scale 2 (stack_h_LR_s2, stack_v_LR_s2) = lf_tools.epi_stacks(LF_LR_s2, y_LR_s2, x_LR_s2, py_LR_s2, px_LR_s2) # make sure the direction of the view shift is the first spatial dimension
# stack_h = np.transpose(stack_h, (0, 2, 1, 3)) # data_source = "/home/mz/PyCharm/Data/testData_s4/super_resolution/HCI/not seen/lf_test_HCI_" # data = sc.loadmat(data_path) name_file = '.hdf5' data_folders = [] data_folders.append('buddha') # data_folders.append('buddha2') # data_folders.append('horses') # data_folders.append('medieval') # data_folders.append('monasRoom') # data_folders.append('papillon') # data_folders.append('stillLife') for i in range(0, len(data_folders)): data_path = data_source + data_folders[i] + name_file f = h5py.File(data_path, 'r') LF = f['LF'].value LF_LR = f['LF_LR'].value (stack_h, stack_v) = lf_tools.epi_stacks(LF, 0, 0, LF.shape[2], LF.shape[3]) (stack_h2, stack_v2) = lf_tools.epi_stacks(LF_LR, 0, 0, LF_LR.shape[2], LF_LR.shape[3]) # stack_h = np.transpose(stack_h, (0, 2, 1, 3)) # for k in range(0, 9): # plt.figure(k) # plt.imshow(stack_h[k, :, :, :]) k = 0