User:Alice/Experiments: Difference between revisions

From XPUB & Lens-Based wiki
Line 3: Line 3:


=Sound to image=
=Sound to image=
Experiments with translating sounds and tones to raw data, and then to images. The resulting image can be superimposed with other images, such as photos and gradients.
==Experiments with translating sounds and tones to raw data, and then to images.==
The resulting image can be superimposed with other images, such as photos and gradients.
[[File:Superimpose sound.jpg|thumbnail]]
[[File:Superimpose sound.jpg|thumbnail]]
==Experiments with generating a gradient using Python==
<source lang='python'>
import math
from PIL import Image
im = Image.new('RGB', (1000, 1000))
ld = im.load()
def gaussian(x, a, b, c, d=0):
    return a * math.exp(-(x - b)**2 / (2 * c**2)) + d
for x in range(im.size[0]):
    r = int(gaussian(x, 231.3135, 666, 201.5447) + gaussian(x, 17.1017, 395.8819, 45))
    g = int(gaussian(x, 129.9851, 157.7571, 108.0298) + gaussian(x, 27.6831, 399.4535, 143.6828))
    b = int(gaussian(x, 3000, 3000, 8.0739) + gaussian(x, 158.8242, 402, 87.0739))
    for y in range(im.size[1]):
        ld[x, y] = (r, g, b)
im.save('test2.png', 'PNG')
</source>
[[File:Test2.png|400px]]

Revision as of 12:54, 4 October 2018

Generating flipbooks from YouTube videos

The script and documentation for this can be found here.

Sound to image

Experiments with translating sounds and tones to raw data, and then to images.

The resulting image can be superimposed with other images, such as photos and gradients.

Superimpose sound.jpg


Experiments with generating a gradient using Python

import math
from PIL import Image
im = Image.new('RGB', (1000, 1000))
ld = im.load()

def gaussian(x, a, b, c, d=0):
    return a * math.exp(-(x - b)**2 / (2 * c**2)) + d

for x in range(im.size[0]):
    r = int(gaussian(x, 231.3135, 666, 201.5447) + gaussian(x, 17.1017, 395.8819, 45))
    g = int(gaussian(x, 129.9851, 157.7571, 108.0298) + gaussian(x, 27.6831, 399.4535, 143.6828))
    b = int(gaussian(x, 3000, 3000, 8.0739) + gaussian(x, 158.8242, 402, 87.0739))
    for y in range(im.size[1]):
        ld[x, y] = (r, g, b)
im.save('test2.png', 'PNG')

Test2.png