我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用skimage.io.ImageCollection()。
def extract_dataset(net_message): assert net_message.layer[0].type == "DenseImageData" source = net_message.layer[0].dense_image_data_param.source with open(source) as f: data = f.read().split() ims = ImageCollection(data[::2]) labs = ImageCollection(data[1::2]) assert len(ims) == len(labs) > 0 return ims, labs
def load_frames(folder_name, offset=0, desired_fps=3, max_frames=40): """ :param folder_name: Filename with a gif :param offset: How many frames into the gif we want to start at :param desired_fps: How many fps we'll sample from the image :return: [T, h, w, 3] GIF """ coll = ImageCollection(folder_name + '/out-*.jpg', mode='RGB') try: duration_path = folder_name + '/duration.txt' with open(duration_path,'r') as f: durs = f.read().splitlines() fps = 100.0/durs[0] except: # Some error occurs fps = 10 # want to scale it to desired_fps keep_ratio = max(1., fps/desired_fps) frames = np.arange(offset, len(coll), keep_ratio).astype(int)[:max_frames] def _add_chans(img): if img.ndim == 3: return img return np.stack([img]*3,-1) imgs_concat = concatenate_images([_add_chans(coll[f]) for f in frames]) assert imgs_concat.ndim == 4 return imgs_concat
def extract_dataset(net_message): assert net_message.layer[0].type == "DenseImageData" source = net_message.layer[0].dense_image_data_param.source with open(source) as f: data = f.read().split() print data ims = ImageCollection(data[::2]) labs = ImageCollection(data[1::2]) assert len(ims) == len(labs) > 0 return ims, labs