Coder Social home page Coder Social logo

marcpartensky / fourier Goto Github PK

View Code? Open in Web Editor NEW
17.0 2.0 6.0 1.67 MB

Make fun of fourier transform.

License: MIT License

Dockerfile 0.17% Python 99.75% Makefile 0.09%
fourier fourier-analysis fourier-methods fourier-optics fourier-series fourier-transform fourier-transformation

fourier's Introduction

Use fourier transform to draw epicycles with your drawings.

Draw a picture or sample one, press space, then watch an epic simulation of epicycles being drawned identically as your picture. Thanks the the fourier transform your drawing will be reproduced in a real-time simulation only using epicycles.

Demo

Fourier Animation

Install

#Clone the repository
git clone https://github.com/MarcPartensky/Fourier.git
cd Fourier

#Install requirements
pip install -r requirements.txt

Usage

Put your model image image.png in the FourierImages folder.

  • Option 1: Give image at launch.
python __main__.py image.png
  • Option 2: Launch then give the image.
python __main__.py
> image name:

Then give your image:

> image name:image.png

Run with docker

# Download the docker-compose.yml file and cd into its parent folder
# Put your image in the FourierImages folder then run
# Replace 'image.png' by your own image filename
docker-compose run --rm fourier image.png

Or choose your own folder

# Download the docker-compose.yml file and cd into its parent folder
# Replace the first occurence of 'FourierImages' by your custom image folder
# Replace 'image.png' by your own image too
docker-compose run --rm \
    -v ./FourierImages:/opt/FourierImages \
    fourier image.png

Or run the full docker command without the docker-compose.yml file

docker run --rm \
-v $PWD/image.jpg:./image.jpg \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/dri \
-e DISPLAY \
marcpartensky/fourier /image.jpg

Or store the coefficients and the images in a folder

docker run --rm \
-v $PWD/FourierImages:/opt/FourierImages \
-v $PWD/FourierObjects:/opt/FourierObjects \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/dri \
-e DISPLAY \
marcpartensky/fourier image.jpg

Description

There are 3 modes in this program:

  • Mode 1: Sampling Sample or draw a picture.

  • Mode 2: Drawing Watch the epicycles simulation which uses fourier transform.

  • Mode 3: Display Get the output image directly without waiting for the simulation.

Controls

  • Space: Switch to next mode.
  • Enter: Go back to the center.
  • Up/Down/Right/Left Arrow: Move arround.
  • Right/Left Shift: Zoom in or out.
  • Quit/Escape: Quit.
  • Z: Cancel last sample.
  • R: Remove all samples.
  • S: Save the fourier-coefficients.

Hide or Show the graphical components

Press the following numbers to toggle:

  • 1: Image
  • 2: Green lines
  • 3: Red graph
  • 4: White vectors
  • 5: Grey circles
  • 6: Yellow sample

Enjoy!

fourier's People

Contributors

marcpartensky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

fourier's Issues

Missing FourierObject/fourier

I followed the README to run your code. But it seems that the config file is missing. The idea of the project is great. I am really wondering how you implement the extraction of outline of people in the image. I try to read your code, but I did not find it.

Add a support SVG files

It would be a good idea to support SVG files so that you don't have to manually draw the path. SVG files are vector images, so the path can be extracted and used to create the drawing.

ZeroDivisionError: division by zero when running demo

On Mac OS with python 3.7:

rohart.jpg
path: /Users/me/tmp/Fourier/FourierImages/rohart.jpg
[Application of the Fourier Transform.] Window has been created.
Traceback (most recent call last):
File "main.py", line 37, in
fourier()
File "/Users/me/tmp/Fourier/fourier_drawing/fourier.py", line 156, in call
self.events()
File "/Users/me/tmp/Fourier/fourier_drawing/fourier.py", line 170, in events
self.setMode((self.mode + 1) % 3)
File "/Users/me/tmp/Fourier/fourier_drawing/fourier.py", line 319, in setMode
self.setConstructionMode()
File "/Users/me/tmp/Fourier/fourier_drawing/fourier.py", line 334, in setConstructionMode
self.coefficients = Fourier.transform(self.sample, self.coefficients_number)
File "/Users/me/tmp/Fourier/fourier_drawing/fourier.py", line 34, in transform
cn /= npts
ZeroDivisionError: division by zero

a clean epicycle simulation

How do I simulate the epicycles just like the demo video?
I just want to make a video out of it without the image or the yellow drawing dots

Video system could not be initialized

I would like to try this out but upon loading it into windows ubuntu
python3 ./Fourier/main.py saint jalm.jpg

it just gives me this error

pygame 2.1.0 (SDL 2.0.16, Python 3.8.10)
Hello from the pygame community. https://www.pygame.org/contribute.html
ALSA lib confmisc.c:767:(parse_card) cannot find card '0'
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_card_driver returned error: No such file or directory
ALSA lib confmisc.c:392:(snd_func_concat) error evaluating strings
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1246:(snd_func_refer) error evaluating name
ALSA lib conf.c:4732:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5220:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2642:(snd_pcm_open_noupdate) Unknown PCM default
path: /home/hunter/FourierImages/saint
[Application of the Fourier Transform.] Window has been created.
Traceback (most recent call last):
File "./Fourier/main.py", line 27, in
context = Context(name="Application of the Fourier Transform.", fullscreen=False)
File "/home/hunter/Fourier/fourier_drawing/context.py", line 418, in init
draw = Draw(**kwargs)
File "/home/hunter/Fourier/fourier_drawing/draw.py", line 35, in init
window = Window(**kwargs)
File "/home/hunter/Fourier/fourier_drawing/window.py", line 49, in init
self.build(size)
File "/home/hunter/Fourier/fourier_drawing/window.py", line 65, in build
self.info = pygame.display.Info()
pygame.error: video system not initialized

Its possible i'm just missing something but I have spent a couple of hours just getting here since for whatever reason nothing wanted to install properly.

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.