def main(src_path, dst_path, image_size): try: for file in image_list(src_path): _, name, ext = split_path(file) save = os.path.join(dst_path, name + ext) #save = os.path.join(dst_path, name+'a' + ext) print(save) resize_image_file(file, image_size, save) #rename(file,save) except IOError: pass # You can always log it to logger
def rename(img_path, save_path): img_path = (norm_path(img_path)) save_path = norm_path(save_path) save_dir, _, _ = split_path(save_path) if not os.path.exists(save_dir): os.makedirs(save_dir) # read image im = cv2.imread(img_path) cv2.imwrite(save_path[:-3] + 'png', im)
def main(data_dir, result_dir, image_size): try: for file in image_list(data_dir): _, name, ext = split_path(file) save = os.path.join(result_dir, name + ext) print(save) resize_image_file(file, image_size, save) make_dataset(data_dir, mask_dir, result_dir) except IOError: pass # You can always log it to logger
def resize_image_file(img_path, image_size, save_path): img_path = (norm_path(img_path)) save_path = norm_path(save_path) save_dir, _, _ = split_path(save_path) if not os.path.exists(save_dir): os.makedirs(save_dir) # read image im = cv2.imread(img_path) # resize image im = resize_image(im, image_size) # write image cv2.imwrite(save_path[:-3] + 'png', im)
def save_tensor_image(input, filename_list=None, path='temp'): if not os.path.isdir(path): os.makedirs(path) image_list = input.cpu().data.numpy() for i, image in enumerate(image_list): # get filename filename = get_increasing_filename() if filename_list is None else filename_list[i] #print(image.shape) image = np.transpose(image, axes=[1, 2, 0]) #print(image.shape) _,file_dir,_ = split_path(filename) # save image scipy.misc.imsave(os.path.join(path, file_dir + '.png'), image.squeeze())
def resize_image_file(img_path, image_size, save_path): img_path = (norm_path(img_path)) save_path = norm_path(save_path) save_dir, _, _ = split_path(save_path) if not os.path.exists(save_dir): os.makedirs(save_dir) # read image im = cv2.imread(img_path) # resize image im = resize_image(im, image_size) # # extract gammma image # greenpath = '/home/bong6/data/mrcnn_cer/classificationdataset_224 (copy)/train/green_type3' # if np.max(im[:, :, 0]) < 60 and np.max(im[:, :, 2]) < 60: # if not os.path.exists(greenpath): # os.makedirs(greenpath) # # shutil.move(img_path, greenpath) # else: # write image cv2.imwrite(save_path[:-3] + 'png', im)