movie.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:k2mosaic 作者: KeplerGO 项目源码 文件源码
def to_movie(self, output_fn, fps=15., dpi=50, cut=None, cmap='gray', extension=1):
        viz = []
        with click.progressbar(self.mosaic_filenames, label="Reading mosaics", show_pos=True) as bar:
            for fn in bar:
                try:
                    frame = KeplerMosaicMovieFrame(fn)
                    fig = frame.to_fig(rowrange=self.rowrange, colrange=self.colrange,
                                       dpi=dpi, cut=cut, cmap=cmap, extension=extension,)
                    img = np.fromstring(fig.canvas.tostring_rgb(), dtype=np.uint8, sep='')
                    img = img.reshape(fig.canvas.get_width_height()[::-1] + (3,))
                    pl.close(fig)  # Avoid memory leak!
                    viz.append(img)
                except InvalidFrameException:
                    print("InvalidFrameException for {}".format(fn))
                    # Save the output as a movie
        if output_fn.endswith('.gif'):
            kwargs = {'duration': 1. / fps}
        else:
            kwargs = {'fps': fps}
        imageio.mimsave(output_fn, viz, **kwargs)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号