Skip to content
Snippets Groups Projects
Commit 928fb7e4 authored by Prof. Dr. Robert Jäschke's avatar Prof. Dr. Robert Jäschke
Browse files

clarified what we do

parent a09d85d4
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:framed-filename tags:
# Computer-generated Art
%% Cell type:markdown id:apart-death tags:
## Unknown Pleasures
This artwork is inspired by [Peter Saville's](https://en.wikipedia.org/wiki/Peter_Saville_(graphic_designer)) cover of the [Joy Division](https://en.wikipedia.org/wiki/Joy_Division) album [Unknown Pleasures](https://en.wikipedia.org/wiki/Unknown_Pleasures). The original [is based on some interesting real data](https://theconversation.com/joy-division-40-years-on-from-unknown-pleasures-astronomers-have-revisited-the-pulsar-from-the-iconic-album-cover-119861) but here we try to imitate it with random data (creating unique pictures). The code demonstrates some mathematical approaches like translation, scaling and composition of functions.
%% Cell type:code id:desperate-hands tags:
```
import numpy as np
import matplotlib.pyplot as plt
k = 50 # number of horizontal points
n = 80 # number of vertical lines
plt.rcParams['figure.figsize'] = (15, 15)
plt.rcParams['figure.dpi'] = 140
plt.style.use('dark_background')
plt.axis('off')
plt.xlim(-100, 200)
plt.ylim(-60, 240)
xs = np.linspace(0, 100, k)
def sq(x, minx, maxx, miny, maxy, invert=False):
x = (x - minx) / (maxx - minx)
if invert:
x = 1 - x
if x < 0.5: # ascent
fx = 2*x**2
else: # descent
fx = (1 - 2*(1-x)**2)
return fx * (maxy - miny) + miny
def f(x, left, right, width, height):
if x < left or x > right: # left + right
return np.abs(np.random.normal(0, .5))
return np.abs(np.random.normal(0, 0.5))
if x < left + width: # ascent
return sq(x, left, left + width, 0, height) + np.abs(np.random.normal(0, 1))
return np.abs(np.random.normal(0, 1.0)) + sq(x, left, left + width, 0, height)
if x > right - width: # descent
return sq(x, right - width, right, 0, height, True) + np.abs(np.random.normal(0, 1))
return np.abs(np.random.normal(0, 1.0)) + sq(x, right - width, right, 0, height, True)
else: # middle
return np.random.exponential(2) + height
for i in range(1, n+1):
data = [f(x, 25, 75, 10, 5) + i*2 for x in xs]
plt.plot(xs, data, color="white", zorder=n-i, linewidth=1)
plt.fill_between(xs, data, color="black", zorder=n-i)
plt.show()
```
......
......@@ -28,7 +28,8 @@ their difficulty (☆ = simple, ☆☆ = advanced, ☆☆☆ = sophisticated):
module "Datenanalyse & -auswertung" (☆☆)
- [[file:amazon_reviews.ipynb][Amazon reviews]] :: crawling web sites with [[https://scrapy.org/][Scrapy]], processing JSON
data, basic statistics and visualisation (☆☆)
- [[file:Art.ipynb][Computer-generated art]] :: inspired by famous artists (☆☆)
- [[file:Art.ipynb][Computer-generated art]] :: translation, scaling and composition of
functions (☆☆)
- [[file:classification.ipynb][Classification]] :: basic machine learning classification example (☆)
- [[file:community_detection.ipynb][Community detection]] :: applying community detection algorithms to
network graphs (☆☆)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment