I'm not going to divulge the details of the model of how to create the sand grains (a current research project of mine). I can tell you I used these rather excellent functions for MATLAB:
Volume interpolation Crust algorithm, described more here
A toolbox for Multi-Parametric Optimisation
I used 'recordmydesktop' to capture the grains in my MATLAB figure window. It created an OGV format video (which I renamed to 'beautiful_grains.ogv'). I then used the following code to decode the video into jpegs
mkdir out_pics
mplayer -ao null -ss 00:00:03 -endpos 50 beautiful_grains.ogv -vo jpeg:outdir=out_pics
I needed to crop the pictures to just the grains, then turn the cropped pictures back into a video. I used this:
cd out_pics
for image in *.jpg
do
# crop the image
convert $image -crop 600x600+350+135 grains%05d.tiff
done
# make movie from the cropped tiffs
ffmpeg -r 25 -i grains%05d.tiff -y -an spinning_grains_small.avi
et voila! Now sit back with a cuppa and relax to those spinning grains.
No comments:
Post a Comment