>>1619The way it basically works is this:
for pixel in image:
let (r', g', b') = f (pixel.r, pixel.g, pixel.b)
pixel.r = combine(pixel.r, r')
pixel.g = combine(pixel.g, g')
pixel.b = combine(pixel.b, b')
Then with different choices for `f` and `combine` you can get different results. The whole process can be iterated with multiple parameter choices to get more interesting effects.
The currently available transformation functions are:
- lightness: (r, g, b) -> (maximum (r, g, b) + minimum (r, g, b)) / 2
- average: (r, g, b) -> (r + g + b) / 3
- luminosity: (r, g, b) -> ceil (0.21 * r + 0.72 * g + 0.07 * b)
- red: (r, g, b) -> r
- green: (r, g, b) -> g
- blue: (r, g, b) -> b
And the combining functions are addition, subtraction, and replacement.
Note that the transformation function only gets told the RGB value of the pixel, nothing more. I need to pass in the entire image and the coordinates or something to do more interesting transformations.
The gifs are pretty simple. Firstly I made all the frames by taking all combinations of two transformations and two combinations:
#!/bin/bash
combines="replace add sub"
transforms="lightness average luminosity red green blue"
for c1 in $combines; do
for t1 in $transforms; do
for c2 in $combines; do
for t2 in $transforms; do
echo $c1 $t1 $c2 $t2
img $c1 $t1 $c2 $t2 lain.jpg lain-$c1-$t1-$c2-$t2.jpg
done
done
done
done
Then lain1.gif is lain.jpg + lain-add*.jpg, lain2.gif is lain.jpg + lain-sub*.jpg, and lain3.gif is lain.jpg + lain-replace*.jpg