Most viewed recipes tagged "image"http://code.activestate.com/recipes/tags/image/views/2017-04-10T21:14:36-07:00ActiveState Code RecipesDraw Text To Image (Python) 2015-07-13T18:04:30-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579013-draw-text-to-image/ <p style="color: grey"> Python recipe 579013 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 2. </p> <p>PIL does not allow resizing default bitmap font. This code resizes it by itself.</p> <p>The disadvantage is slow speed but the advantage is it becomes possible to set color of each pixel of text foreground and background.</p> <p>As an example I set foreground to reverse colors and background to grayscale.</p> 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> Mandelbrot fractal using PIL (Python) 2010-03-26T04:39:46-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577111-mandelbrot-fractal-using-pil/ <p style="color: grey"> Python recipe 577111 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). Revision 2. </p> <p>Mandelbrot fractal using Python Image Library (PIL).</p> 2D Discrete Fourier Transform (Python) 2015-01-03T03:39:34-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578997-2d-discrete-fourier-transform/ <p style="color: grey"> Python recipe 578997 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/signal_processing/">signal_processing</a>). </p> <p>2D Discrete Fourier Transform (DFT) and its inverse.</p> <p>Calculates 2D DFT of an image and recreates the image using inverse 2D DFT.</p> <p>Computation is slow so only suitable for thumbnail size images.</p> Image to ASCII Art Converter (Python) 2016-09-25T21:24:12-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580702-image-to-ascii-art-converter/ <p style="color: grey"> Python recipe 580702 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>ASCII Art Generator (Image to ASCII Art Converter)</p> <p>Input file maybe JPG, PNG, GIF etc. Output file name maybe output.txt etc.</p> Convolving Gaussian (Python) 2009-05-19T05:23:48-07:00alexander bakerhttp://code.activestate.com/recipes/users/4166679/http://code.activestate.com/recipes/576764-convolving-gaussian/ <p style="color: grey"> Python recipe 576764 by <a href="/recipes/users/4166679/">alexander baker</a> (<a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Convolving Gaussian</p> Polynomial Interpolation using Lagrange Polynomial (Python) 2010-11-28T03:03:36-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577474-polynomial-interpolation-using-lagrange-polynomial/ <p style="color: grey"> Python recipe 577474 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Polynomial Interpolation (curve-fitting) using Lagrange Polynomial.</p> Bifurcation diagram of logistic map (Python) 2010-07-24T02:40:54-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577332-bifurcation-diagram-of-logistic-map/ <p style="color: grey"> Python recipe 577332 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). Revision 2. </p> <p>Bifurcation diagram of the logistic map.</p> Sort images from different sources by picture taken date (Exif) (Python) 2013-09-24T12:43:31-07:00Rutger Saalminkhttp://code.activestate.com/recipes/users/4187940/http://code.activestate.com/recipes/578672-sort-images-from-different-sources-by-picture-take/ <p style="color: grey"> Python recipe 578672 by <a href="/recipes/users/4187940/">Rutger Saalmink</a> (<a href="/recipes/tags/chronological/">chronological</a>, <a href="/recipes/tags/exif/">exif</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/order/">order</a>, <a href="/recipes/tags/photo/">photo</a>, <a href="/recipes/tags/picture/">picture</a>). Revision 3. </p> <p>On some occasions/events, pictures will be taken by different camera's, mobile phones, etc. In order to sort these photos chronologically, it does not suffice using the file's date modified/created set by the OS. The following script obtains, from multiple sources, the pictures' taken date stored in the accompanying Exif data and outputs them all chronologically in a single directory.</p> Bezier Curve using De Casteljau algorithm (Python) 2011-11-25T02:33:54-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577961-bezier-curve-using-de-casteljau-algorithm/ <p style="color: grey"> Python recipe 577961 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Draws a random Bezier Curve using De Casteljau algorithm.</p> Reaction Diffusion Simulation (Python) 2015-10-16T19:52:02-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579114-reaction-diffusion-simulation/ <p style="color: grey"> Python recipe 579114 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/chaos/">chaos</a>, <a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/physics/">physics</a>, <a href="/recipes/tags/simulation/">simulation</a>). Revision 2. </p> <p>Reaction-Diffusion Simulation using Gray-Scott Model.</p> Newton Fractals (Python) 2010-03-30T04:50:09-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577166-newton-fractals/ <p style="color: grey"> Python recipe 577166 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). </p> <p>It draws the Newton fractal of any given complex-variable function.</p> Random Planet Generator Using Plasma Fractal (Python) 2016-01-25T23:05:25-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580495-random-planet-generator-using-plasma-fractal/ <p style="color: grey"> Python recipe 580495 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Random Planet Generator using 3D Plasma Fractal and Voxel-based Ray Tracing for rendering.</p> <p>Instead of generating 2D Plasma Fractal and projecting onto sphere, it generates 3D Plasma Fractal (cube) and cuts sphere from it.</p> Image Projection Onto Sphere (Python) 2016-07-31T22:50:28-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/580695-image-projection-onto-sphere/ <p style="color: grey"> Python recipe 580695 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/image_processing/">image_processing</a>, <a href="/recipes/tags/imaging/">imaging</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>Image projection onto sphere using Equirectangular map projection.</p> <p>Download the test image from the Wikipedia page!</p> Perlin Noise Generator (Python) 2013-02-23T05:23:24-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578470-perlin-noise-generator/ <p style="color: grey"> Python recipe 578470 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). Revision 2. </p> <p>Perlin Noise Generator using Bilinear Interpolation.</p> Voxel Based Ray Tracing (Python) 2013-08-29T06:11:41-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578652-voxel-based-ray-tracing/ <p style="color: grey"> Python recipe 578652 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>The standard ray tracing algorithm seems unnatural to me because everytime a ray reflects/refracts all (primitive) objects in the scene must be tested for intersection; no matter where they located!</p> <p>In this method there is no such thing. It just moves each ray voxel by voxel until it hits an opaque/reflective(/refractive) voxel.</p> <p>I made many simplifications so the image is crude.</p> Metro Spinner for Tkinter (Python) 2017-04-10T21:14:36-07:00Miguel Martínez Lópezhttp://code.activestate.com/recipes/users/4189907/http://code.activestate.com/recipes/580777-metro-spinner-for-tkinter/ <p style="color: grey"> Python recipe 580777 by <a href="/recipes/users/4189907/">Miguel Martínez López</a> (<a href="/recipes/tags/canvas/">canvas</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/pil/">pil</a>, <a href="/recipes/tags/rotation/">rotation</a>, <a href="/recipes/tags/spinner/">spinner</a>, <a href="/recipes/tags/tkinter/">tkinter</a>). </p> <p>I create a rotating image class <em>RotatingIcon</em> inspired and based on this code:</p> <p><a href="http://stackoverflow.com/questions/15736530/python-tkinter-rotate-image-animation" rel="nofollow">http://stackoverflow.com/questions/15736530/python-tkinter-rotate-image-animation</a></p> <p>Features:</p> <ul> <li>Methods to stop and start the animation</li> <li>The animation automically stops when the window is not mapped, and the animation continues when the window is mapped again</li> <li>Time setting to control the speed of the animation</li> <li>All the formats accepted for PIL could be used. XBM format is automatically converted to Tk Bitmap. The advantage of Bitmats is the possibility to change the color of the foreground.</li> </ul> <p>I added 6 different styles of spinners with different sizes.</p> <p>I used fontawesome.io for the icon generation.</p> <p>For more metro widgets see here:</p> <p><a href="https://code.activestate.com/recipes/580729-metro-ui-tkinter/" rel="nofollow">https://code.activestate.com/recipes/580729-metro-ui-tkinter/</a></p> Quasicrystal Pattern Generator (Python) 2015-08-08T20:50:23-07:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/579094-quasicrystal-pattern-generator/ <p style="color: grey"> Python recipe 579094 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/images/">images</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>). </p> <p>Quasicrystal Pattern Generator</p> Bilinear Interpolation (Python) 2013-02-23T04:00:52-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/578469-bilinear-interpolation/ <p style="color: grey"> Python recipe 578469 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/graphics/">graphics</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/mathematics/">mathematics</a>, <a href="/recipes/tags/pil/">pil</a>). </p> <p>Creates a surface from a grid of random numbers using Bilinear Interpolation.</p> Mandelbrot Fractal using HTML5 Canvas (JavaScript) 2012-12-28T01:01:09-08:00FB36http://code.activestate.com/recipes/users/4172570/http://code.activestate.com/recipes/577277-mandelbrot-fractal-using-html5-canvas/ <p style="color: grey"> JavaScript recipe 577277 by <a href="/recipes/users/4172570/">FB36</a> (<a href="/recipes/tags/fractal/">fractal</a>, <a href="/recipes/tags/image/">image</a>, <a href="/recipes/tags/math/">math</a>). Revision 3. </p> <p>Mandelbrot Fractal using HTML5 Canvas. (Do not forget to change file extension to HTML after downloading it.)</p>