This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def countless(data): | |
""" | |
Vectorized implementation of downsampling a 2D | |
image by 2 on each side using the COUNTLESS algorithm. | |
data is a 2D numpy array with even dimensions. | |
""" | |
# allows us to prevent losing 1/2 a bit of information | |
# at the top end by using a bigger type. Without this 255 is handled incorrectly. | |
data, upgraded = upgrade_type(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def zero_corrected_countless(data): | |
""" | |
Vectorized implementation of downsampling a 2D | |
image by 2 on each side using the COUNTLESS algorithm. | |
data is a 2D numpy array with even dimensions. | |
""" | |
# allows us to prevent losing 1/2 a bit of information | |
# at the top end by using a bigger type. Without this 255 is handled incorrectly. | |
data, upgraded = upgrade_type(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def simplest_countless(data): | |
""" | |
Vectorized implementation of downsampling a 2D | |
image by 2 on each side using the COUNTLESS algorithm. | |
data is a 2D numpy array with even dimensions. | |
""" | |
sections = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get bcmatch from http://www.fmwconcepts.com/imagemagick/bcmatch/index.php | |
if [ ! -e frames_adj ]; then | |
echo "adjusting for brightness/contrast" | |
mkdir frames_adj | |
for fname in `ls frames`; do | |
./bcmatch frames/07.png frames/$fname frames_adj/$fname | |
done | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FILENAME=$1 | |
FPS=${2:-24} | |
SPEEDUP=${3:-100} | |
echo "FILENAME: $FILENAME, FPS: $FPS, RATE: $SPEEDUP%" | |
mkdir -p frames | |
touch frames/tmp.txt # make rm not fail if frames is empty | |
rm frames/* | |
ffmpeg -threads 0 -i "$FILENAME" -vf scale=700:-1:flags=lanczos,fps=$FPS frames/ffout%03d.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PI = 3.14159265359 | |
exp(x) | |
return math(x, 'exp') | |
sqrt(x) | |
return math(x, 'sqrt') | |
atan(x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: I found out stylus has math(x, 'sqrt') after the fact | |
sqrt(y) | |
if y < 0 | |
error("Unable to process complex roots.") | |
if y == 0 // for floating point precision | |
return 0 | |
else if y == 1 // for floating point precision | |
return 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* easeOutFactory | |
* | |
* Generate an ease-out function with desired steepness. | |
* Article: https://medium.com/analytic-animations/ease-out-the-half-sigmoid-7240df433d98#.yupto8l43 | |
* | |
* Note: Values below 6 may not come to a smooth stop. | |
* | |
* Required: | |
* k: (float), sharpness of ease | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Volume needs to lease the data cube | |
class Volume { | |
constructor (args) { | |
this.channel_id = args.channel_id; // volume id as corresponding to the data server | |
this.segmentation_id = args.segmentation_id; | |
this.bounds = args.bounds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* springFactory | |
* | |
* Generate a physically realistic easing curve for a damped mass-spring system. | |
* | |
* Required: | |
* damping (zeta): [0, 1) | |
* halfcycles: 0...inf | |
* | |
* Optional: | |
* initial_position: -1..1, default 1 |