当前位置: 首页>>代码示例>>Python>>正文


Python imageio.mimwrite方法代码示例

本文整理汇总了Python中imageio.mimwrite方法的典型用法代码示例。如果您正苦于以下问题:Python imageio.mimwrite方法的具体用法?Python imageio.mimwrite怎么用?Python imageio.mimwrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在imageio的用法示例。


在下文中一共展示了imageio.mimwrite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_gif

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def make_gif(screenshot_dir_path,name = "test_recap",suffix=".gif",duration=2):
    "Creates gif of the screenshots"
    gif_name = None
    images = []

    if "/" in name:
        name=name.split("/")[-1]

    filenames = os.listdir(screenshot_dir_path)
    if len(filenames) != 0:
        gif_name = os.path.join(screenshot_dir_path, name + suffix)
        for files in sorted(filenames):
            images.append(imageio.imread(os.path.join(screenshot_dir_path, files)))
        imageio.mimwrite(gif_name, images, duration=duration)

    return gif_name 
开发者ID:qxf2,项目名称:qxf2-page-object-model,代码行数:18,代码来源:Gif_Maker.py

示例2: main

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def main():
    assert len(sys.argv) >= 2
    d = sys.argv[1]

    fps = glob(osp.join(d, '*.jpg'))
    fps = sorted(fps, key=lambda x: int(x.split('/')[-1].replace('.jpg', '')))

    imgs = []
    for fp in fps:
        img = imageio.imread(fp)
        imgs.append(img)

    if len(sys.argv) >= 3:
        imageio.mimwrite(sys.argv[2], imgs, fps=24, macro_block_size=None)
    else:
        imageio.mimwrite(osp.basename(d) + '.mp4', imgs, fps=24, macro_block_size=None) 
开发者ID:cleardusk,项目名称:3DDFA,代码行数:18,代码来源:convert_imgs_to_video.py

示例3: make_banner

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def make_banner(self, text: str, colour: str) -> BytesIO:
        im = Image.new("RGBA", (300, 100), (0, 0, 0, 0))
        font = ImageFont.truetype(str(bundled_data_path(self) / "impact.ttf"), 18)
        draw = ImageDraw.Draw(im)
        size_w, size_h = draw.textsize(text, font=font)
        W, H = (size_w + 25, 100)

        images = []
        for i in range(0, W):
            im = Image.new("RGBA", (W, H), colour)
            draw = ImageDraw.Draw(im)
            draw.text((((W - size_w) / 2) - i, (100 - size_h) / 2), text, font=font, fill="white")
            draw.text((10 + W - i, (100 - size_h) / 2), text, font=font, fill="white")
            images.append(np.array(im))

        temp = BytesIO()
        temp.name = "temp.gif"
        imageio.mimwrite(temp, images, "gif", duration=0.02)
        temp.seek(0)
        return temp 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:22,代码来源:imagemaker.py

示例4: save_observation_series_to_gif

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def save_observation_series_to_gif(batched_observation_series,
                                   fpath,
                                   solved_states=None):
    """Saves a list of arrays of intermediate scenes as a gif."""
    max_steps = max(len(img) for img in batched_observation_series)
    images_per_step = []
    for step in range(max_steps):
        images_for_step = []
        for i, images in enumerate(batched_observation_series):
            real_step = min(len(images) - 1, step)
            if solved_states is None:
                solved = None
            else:
                solved = solved_states[i]
            images_for_step.append(
                observations_to_uint8_rgb(images[real_step], is_solved=solved))
        images_for_step = np.concatenate(images_for_step, axis=1)
        images_per_step.append(images_for_step)

    imageio.mimwrite(fpath, images_per_step, format="gif") 
开发者ID:facebookresearch,项目名称:phyre,代码行数:22,代码来源:vis.py

示例5: save_gif

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def save_gif(self, filename=None):
        """Save the stored GIF frames to a file.

        To use this asynchronously, run the viewer with the ``record``
        flag and the ``run_in_thread`` flags set.
        Kill the viewer after your desired time with
        :meth:`.Viewer.close_external`, and then call :meth:`.Viewer.save_gif`.

        Parameters
        ----------
        filename : str
            The file to save the GIF to. If not specified,
            a file dialog will be opened to ask the user where
            to save the GIF file.
        """
        if filename is None:
            filename = self._get_save_filename(['gif', 'all'])
        if filename is not None:
            self.viewer_flags['save_directory'] = os.path.dirname(filename)
            imageio.mimwrite(filename, self._saved_frames,
                             fps=self.viewer_flags['refresh_rate'],
                             palettesize=128, subrectangles=True)
        self._saved_frames = [] 
开发者ID:musyoku,项目名称:gqn-dataset-renderer,代码行数:25,代码来源:viewer.py

示例6: make_anishot

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def make_anishot():
    image = Image.fromarray(imageio.imread(ARGS.input.name))
    frames = []

    if ARGS.zoom_steps:
        make_zoomin(image, frames)
    make_scroll(image, frames)

    imageio.mimwrite(ARGS.output,
                     map(lambda f: numpy.array(f[0]), frames),
                     duration=list(map(lambda f: f[1], frames))) 
开发者ID:sourcerer-io,项目名称:anishot,代码行数:13,代码来源:__main__.py

示例7: _save_gif

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def _save_gif(self):
        # Get save file location
        try:
            root = Tk()
            fn = ''
            if self._save_filename:
                fn = '{}.gif'.format(self._save_filename)
            filename = filedialog.asksaveasfilename(initialfile = fn,
                                                    initialdir = (self._save_directory or os.getcwd()),
                                                    title = 'Select file save location',
                                                    filetypes = (('gif files','*.gif'),
                                                                ('all files','*.*')))
        except:
            logging.warning('Cannot use Tkinter file dialogs over SSH')
            self._saved_frames = []
            return

        root.destroy()
        if filename == ():
            self._saved_frames = []
            return
        else:
            self._save_directory = os.path.dirname(filename)

        imageio.mimwrite(filename, self._saved_frames, fps=30.0, palettesize=128, subrectangles=True)

        self._saved_frames = [] 
开发者ID:BerkeleyAutomation,项目名称:meshrender,代码行数:29,代码来源:viewer.py

示例8: _save_movie_data

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def _save_movie_data(fname, data, fps, fmt):
    if fmt == 'gif':
        imageio.mimwrite(fname+'.gif', data,
                         duration=1/fps, subrectangles=True)
    else:
        imageio.mimwrite(fname + '.' + fmt, data,
                         fps=fps, macro_block_size=SPRITE_SIZE,
                         ffmpeg_log_level='quiet') 
开发者ID:PartnershipOnAI,项目名称:safelife,代码行数:10,代码来源:render_graphics.py

示例9: png2tiff

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def png2tiff(ofn: Path, pat: str, indir: Path = None):
    """
    convert series of PNG, which may not be exactly the same shape,
    to a multipage TIFF (in the same directory)

    alternatives: use ImageMagick from command line, or Wand.
    however, since the files are grouped in a specific weird way, the histfeas program
    worked best to have this perhaps ImageMagick duplicative functionality in
    Python/imageio/skimage.
    """
    if resize is None:
        raise ImportError('pip install scikit-image')

    ofn = Path(ofn).expanduser()
    indir = ofn.parent if indir is None else Path(indir).expanduser()
# %% convert these sets of images to multipage image
    flist = sorted(indir.glob(pat))  # yes, sorted()
    if not flist:
        raise FileNotFoundError('found no files with {pat} in {ofn}')

    im0 = imageio.imread(flist[0])  # priming read
    images = np.empty((len(flist), *im0.shape), dtype=im0.dtype)
    for i, f in enumerate(flist):
        im = imageio.imread(f)
        images[i, ...] = resize(im, im0.shape, mode='edge')  # they are all of slightly different shape

    imageio.mimwrite(ofn, images) 
开发者ID:scivision,项目名称:pyimagevideo,代码行数:29,代码来源:__init__.py

示例10: save_data

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def save_data(self):
        if self.base_dir is not None:
            if self.dc is not None:
                # save the stimulus movie if it is generated
                movie, movie_times = self.window_display.widget_display.get_movie()
                if movie is not None:
                    if self.stim_movie_format == "h5":
                        movie_dict = dict(
                            movie=np.stack(movie, 0), movie_times=movie_times
                        )
                        fl.save(
                            self.filename_base() + "stim_movie.h5",
                            movie_dict,
                            compression="blosc",
                        )
                    elif self.stim_movie_format == "mp4":
                        imageio.mimwrite(
                            self.filename_base() + "stim_movie.mp4",
                            movie,
                            fps=30,
                            quality=None,
                            ffmpeg_params=[
                                "-pix_fmt",
                                "yuv420p",
                                "-profile:v",
                                "baseline",
                                "-level",
                                "3",
                            ],
                        )
                    else:
                        raise Exception(
                            "Tried to write the stimulus video into an unsupported format"
                        )
        super().save_data() 
开发者ID:portugueslab,项目名称:stytra,代码行数:37,代码来源:__init__.py

示例11: save_animation

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def save_animation(list_of_animated_images, image_path, fps):
  full_size_images = []
  for single_images in zip(*list_of_animated_images):
    full_size_images.append(
        pad_around(add_below(padded_grid(list(single_images)))))
  imageio.mimwrite(image_path, full_size_images, fps=fps) 
开发者ID:google-research,项目名称:disentanglement_lib,代码行数:8,代码来源:visualize_util.py

示例12: _make_gif

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def _make_gif(input_png_path):
  png_filenames = [t for t in os.listdir(input_png_path) if t.endswith('.png')]
  png_filenames = sort_filename(png_filenames)
  out_gif_filename = os.path.join(input_png_path, 'plot.gif')
  images = []
  for filename in png_filenames:
    images.append(imageio.imread(os.path.join(input_png_path, filename)))
  imageio.mimwrite(out_gif_filename, images, duration=0.5, loop=0) 
开发者ID:google,项目名称:mentornet,代码行数:10,代码来源:visualizer.py

示例13: face_transition

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def face_transition(self, images: list) -> BytesIO:
        img_list = []
        # base = Image.open(images[-1])
        for image in images[:-1]:
            overlay = Image.open(image)
            overlay = overlay.resize((256, 256), Image.ANTIALIAS)
            overlay = overlay.convert("RGBA")
            if len(overlay.split()) != 4:
                alpha = Image.new("L", overlay.size, 255)
            else:
                alpha = overlay.convert("L")  # Image.new("L", overlay.size, 255)
            overlay.putalpha(alpha)
            for i in range(0, 50):
                base_img = Image.open(images[-1])
                base_img = base_img.convert("RGBA")
                base_img = base_img.resize((256, 256), Image.ANTIALIAS)
                paste_mask = overlay.split()[3].point(lambda x: x * i / 50)
                base_img.paste(overlay, (0, 0), paste_mask)
                img_list.append(np.array(base_img))
            for i in range(49, -1, -1):
                base_img = Image.open(images[-1])
                base_img = base_img.convert("RGBA")
                base_img = base_img.resize((256, 256), Image.ANTIALIAS)
                paste_mask = overlay.split()[3].point(lambda x: x * i / 50)
                base_img.paste(overlay, (0, 0), paste_mask)
                img_list.append(np.array(base_img))
        # print(len(img_list))
        temp = BytesIO()
        temp.name = "merge.gif"
        imageio.mimwrite(temp, img_list, "gif", duration=0.02)
        return temp 
开发者ID:TrustyJAID,项目名称:Trusty-cogs,代码行数:33,代码来源:imagemaker.py

示例14: compose_gifs_compact

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def compose_gifs_compact(input_fpathes, output_fpath):
    """Create progressin for first and last frames over time."""
    first_and_last_per_batch_id = []
    for fname in input_fpathes:
        data = imageio.mimread(fname)
        data = np.concatenate([data[0], data[-1]], axis=0)
        first_and_last_per_batch_id.append(data)
    if first_and_last_per_batch_id:
        imageio.mimwrite(output_fpath, first_and_last_per_batch_id) 
开发者ID:facebookresearch,项目名称:phyre,代码行数:11,代码来源:vis.py

示例15: compose_gifs

# 需要导入模块: import imageio [as 别名]
# 或者: from imageio import mimwrite [as 别名]
def compose_gifs(input_fpathes, output_fpath):
    """Concatenate and sync all gifs."""
    all_data = []
    for fname in input_fpathes:
        all_data.append(imageio.mimread(fname))
    max_timestamps = max(len(data) for data in all_data)

    def _pad(data):
        return data + [data[-1]] * (max_timestamps - len(data))

    all_data = np.concatenate([_pad(data) for data in all_data], 1)
    imageio.mimwrite(output_fpath, all_data) 
开发者ID:facebookresearch,项目名称:phyre,代码行数:14,代码来源:vis.py


注:本文中的imageio.mimwrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。