Images
15 posts on images. All posts · RSS feed
-
-
Floyd-Steinberg Dithering
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 …
-
Approximating images with overlapping straight lines
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 …
-
Matching coloured LED combinations to a spectrum
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 …
-
Logistic regression for image classification
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 …
-
Cropping a square region from an image
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 …
-
Turning an image into a sticker chart
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 …
-
An object-oriented SVG torus
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 …
-
Depicting a torus as an SVG image
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, …
-
Generating an SVG clock face
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 …