https://github.com/thinking-tower/fourier-and-images
Fourier and Images
https://github.com/thinking-tower/fourier-and-images
fourier fourier-analysis fourier-series image-manipulation image-processing math mathematics numpy opencv opencv-python opencv3-python python python3 scipy signal-analysis signal-processing
Last synced: 4 months ago
JSON representation
Fourier and Images
- Host: GitHub
- URL: https://github.com/thinking-tower/fourier-and-images
- Owner: thinking-tower
- License: mit
- Created: 2018-05-05T09:41:28.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-10-12T23:07:26.000Z (over 3 years ago)
- Last Synced: 2024-11-07T09:02:38.630Z (4 months ago)
- Topics: fourier, fourier-analysis, fourier-series, image-manipulation, image-processing, math, mathematics, numpy, opencv, opencv-python, opencv3-python, python, python3, scipy, signal-analysis, signal-processing
- Language: Python
- Homepage:
- Size: 59.1 MB
- Stars: 85
- Watchers: 7
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fourier and Images
[](https://travis-ci.org/thinking-tower/Fourier-and-Images)
Fourier and Images is a project that tries to draw images with circles.
## Setup
1. `pip3 install -r requirements.txt`
1. Modify `main.py` to reflect where your images are.
1. `python3 main.py`Note that you'll need ImageMagick only if you want to save stuff to a gif.
## Example
Getting one set of circles with one image:
```
im = Image("pikachu.png", (200, 200))
path = im.sort()
period, tup_circle_rads, tup_circle_locs = Fourier(n_approx = 1000, coord_1 = path).get_circles()
Plot(period, tup_circle_rads, tup_circle_locs, speed = 8).plot()
```[](https://github.com/thinking-tower/Fourier-and-Images/blob/master/example_gifs/pikachu.gif "Pikachu")
> Pikachu
Getting two sets of circles with one image:
```
im = Image("einstein.jpg", (200, 200))
path = im.sort()
period, tup_circle_rads, tup_circle_locs = Fourier(n_approx = 1000, coord_1 = path).get_circles(mode=2)
Plot(period, tup_circle_rads, tup_circle_locs, speed = 8).plot()
```
Note that the circle on the bottom left is NOT drawing any particular image.[](https://github.com/thinking-tower/Fourier-and-Images/blob/master/example_gifs/einstein.gif "Einstein")
> Einstein
Getting two set of circles with two image:
```
im_1 = Image("images/formula.jpeg", (200, 200))
im_2 = Image("images/dickbutt.jpg", (200, 200))
path_1 = im_1.sort()
path_2 = im_2.sort()
period, tup_circle_rads, tup_circle_locs = Fourier(n_approx = 1000, coord_1 = path_1, coord_2 = path_2).get_circles()
Plot(period, tup_circle_rads, tup_circle_locs, speed = 8).plot()
```[](https://github.com/thinking-tower/Fourier-and-Images/blob/master/example_gifs/dickbutt_formula.gif "Dickbutt and Euler's Formula")
> Dickbutt and Euler's Formula
Getting visualization of how number of Fourier Series terms affects the image:
```
im = Image("images/obama.jpg", (200, 200))
path = im.sort()
period, tup_circle_rads, tup_circle_locs = Fourier(coord_1 = path).get_circles()
Plot(period, tup_circle_rads, tup_circle_locs, visualize = True).plot()
```[](https://github.com/thinking-tower/Fourier-and-Images/blob/master/example_gifs/obama.gif "Obama")
> Obama
# Warnings
Too big of an image might cause your computer to freeze! Resizing the image to (200, 200) is a safe choice and anything above (500, 500) starts to get a bit sketchy.# Animation
Anything above 1000 n_approximations takes a bit of time to animate. Recommend speed = 8. In this setting, saving the animation takes about 10 minutes.# Improvements
1) Use FFT to calculate the Fourier Series coefficients
2) Improve edge detection algorithm
3) Improve the function(s) that order the points from the edge detection algorithmHave fun!