ASCII art depicts an image with the printable characters of the ASCII (American Standard Code for Information Interchange) character set, each character standing for the brightness of a small region of the image through the density of its glyph. This post introduces a Python script …
Floyd-Steinberg dithering is a technique for reducing the colour palette of an image (for example, to reduce its file size) whilst keeping as much of the perceived detail as possible. For each pixel in the original image, the nearest colour to that pixel is chosen …
Just a quick script to approximate a given target image from a large number of overlapping straight lines. The algorithm is rather inefficient: each line is added to several copies of the the approximation so far, and the best one chosen (ie the one that …
A previous blog post provides a class, ColourSystem, which can be used to predict the colour (within some colour system) of a provided spectrum. This post uses the class to determine how to combine a number of light emitting diodes (LEDs), or other light sources …
Simple logistic regression is a statistical method that can be used for binary classification problems. In the context of image processing, this could mean identifying whether a given image belongs to a particular class () or not (), e.g. "cat" or "not cat". A logistic …
For a basic logistic regression image classification exercise, it is usually desirable for the training and test images to have the same dimensions and images are often chosen to be square. However, many datasets provide images with different sizes and aspect ratios for more advanced …
To produce a children's sticker chart from a provided image, the following code divides it into squares (which can be cut out) and produces further images with matching labels for the reverse side of the printed image and a piece of card onto which the …
The code below, torus.py, defines a class Torus for drawing an SVG image of a torus. The Torus class itself is a subclass of Shape, a more general class for depicting 3D objects in an SVG image, defined in shape.py. A usage example is given …
SVG may not be the most obvious choice for depicting a 3-D object, but with some care over the perspective and ordering of the plotted points, it can be done. The code is below and relies on a single import for the colour scheme, palettes.py, …
This is a simple Python function to generate a clock face indicating a specified time. It can be used in the script below to generate 1, 2, 4 or 6 faces indicating random times to teach children how to tell the time. Run this script …