Popular recipes tagged "manipulation"http://code.activestate.com/recipes/tags/manipulation/2011-02-02T12:50:58-08:00ActiveState Code Recipesinterleave bits (aka morton-ize aka z-order curve) (Python) 2011-02-02T12:50:58-08:00Romain Dartigueshttp://code.activestate.com/recipes/users/4167472/http://code.activestate.com/recipes/577558-interleave-bits-aka-morton-ize-aka-z-order-curve/ <p style="color: grey"> Python recipe 577558 by <a href="/recipes/users/4167472/">Romain Dartigues</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/bits/">bits</a>, <a href="/recipes/tags/manipulation/">manipulation</a>, <a href="/recipes/tags/mathematical/">mathematical</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>This recipe let you encode in a single number two or three numbers.</p> <p>Note: this is only an adaptation of the recipes from <strong>Sean Eron Anderson</strong> and <strong>Fabian “ryg” Giesen</strong>; all credits goes to the respective authors.</p> <ul> <li><a href="http://graphics.stanford.edu/%7Eseander/bithacks.html#InterleaveBMN" rel="nofollow">http://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN</a></li> <li><a href="http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/" rel="nofollow">http://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/</a></li> </ul> Floyd-Steinberg dithering algorithm (Python) 2009-06-02T01:28:46-07:00Alan Holthttp://code.activestate.com/recipes/users/4170480/http://code.activestate.com/recipes/576788-floyd-steinberg-dithering-algorithm/ <p style="color: grey"> Python recipe 576788 by <a href="/recipes/users/4170480/">Alan Holt</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/dithering/">dithering</a>, <a href="/recipes/tags/floyd_steinberg/">floyd_steinberg</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/manipulation/">manipulation</a>). </p> <p>Floyd-Steinberg dithering is an image dithering algorithm (see <a href="http://en.wikipedia.org/wiki/Floyd-Steinberg" rel="nofollow">http://en.wikipedia.org/wiki/Floyd-Steinberg</a> for more details). While the algorithm is mainly for image manipulation, I use it to create random locations for sensor networt devices.</p> Interleaving file lines using iterators (Python) 2009-02-23T04:07:37-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576665-interleaving-file-lines-using-iterators/ <p style="color: grey"> Python recipe 576665 by <a href="/recipes/users/4124829/">David Moss</a> (<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/manipulation/">manipulation</a>). </p> <p>Accepts one of more files and/or globs and interleaves the lines from each writing the result to stdout.</p>