Giter Club home page Giter Club logo

picture_tsne's Introduction

Image to GIF Converter

这是一个使用R语言编写的脚本,它可以将用户提供的图片转换为一个动态的GIF。

脚本描述

这个脚本首先加载所需的库,包括ggplot2gganimatepngEBImageRtsne

然后,脚本读取一个名为"Tiananmen_beijing_Panorama.jpg"的图片,并将其旋转90度。图片被分割为50行和50列的块。

接着,脚本计算每个块的颜色平均值,并将这些颜色值存储在一个三维数组中。这个三维数组然后被重塑为一个二维矩阵。

然后,脚本添加一些噪声到颜色数据,并使用t-SNE算法将颜色数据降维到二维空间。

接着,脚本创建一个动画数据集,这个数据集包含每个颜色块在二维空间中的位置,以及它们的颜色值。

然后,脚本使用ggplot2和gganimate包创建一个动画,这个动画显示了颜色块在二维空间中的移动。这个动画被保存为"animation.gif"。

使用方法

  1. 确保你的R环境中已经安装了ggplot2gganimatepngEBImageRtsne这些包。如果没有安装,你可以使用install.packages()函数来安装。

  2. 将你想要转换的图片命名为"Tiananmen_beijing_Panorama.jpg",并将其放在你的R脚本的同一目录下。

  3. 运行脚本。脚本会读取你的图片,将其分割为50行和50列的块,然后计算每个小块的颜色平均值。然后,脚本会使用t-SNE算法将颜色数据降维,并创建一个动画数据集。

  4. 脚本会使用ggplot2和gganimate包创建一个动画,并将其保存为"animation.gif"。

注意事项

  • 你可以根据需要修改脚本中的参数,例如图片的路径、图像的大小和块的大小等。

  • 这个脚本使用的是t-SNE算法,这是一种非线性降维方法,用于将高维数据映射到低维空间。这意味着每次运行脚本时,生成的GIF可能会有所不同。

  • 生成的GIF将会保存在你的R脚本的同一目录下,你可以在那里找到它。

  • 这个脚本需要一些时间来运行,具体的时间取决于你的图片的大小和你的计算机的性能。

picture_tsne's People

Contributors

chr991004 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.