Python’s math module provides a range of trigonometric functions and in this article I will use them to provide a crash course in trigonometry.
If we have the length of two sides of a right-angled triangle*, or the length of one side and one angle, we can calculate the other lengths and angles. This is known as “solving” the triangle, and is used in areas as diverse as surveying to 3D graphics. The functions involved, particularly the sine, can also be used as the basis for formulas representing cyclical or oscillating behaviour, and is even used in JPEG compression.
Math object. This includes a wider selection of trigonometric functions than
Math and in this post I will use them to provide a crash course in trigonometry.
If we have the length of two sides of a right-angled triangle*, or the length of one side and one angle, we can calculate the other lengths and angles. This is known as “solving” the triangle, and is used in areas as diverse as surveying to 3D graphics. …
img src in an HTML document. This is useful for small images such as logos or button graphics to reduce the number of HTTP requests, and although I am using HTML the Base 64 string can also be used in CSS.
As you probably know, base 10…
The JIMP npm package provides us with methods to compare image files for the purposes of identifying inadvertent duplication or deliberate plagiarism. In this article I will demonstrate how to use them, and along the way we will find out just how similar two images must be to be considered the same.
If you just want to install it for this project then run:
npm install --save jimp
I will be using three methods for comparing images:
hash: this returns a 64…
A while ago I wrote a post on implementing the Caesar Shift Cipher in Python. I will now expand on the theme by implementing the Vigenère Cipher.
The Vigenère Cipher was invented in 1553 by the Italian Giovan Battista Bellaso but is now erroniously named after the Frenchman Blaise de Vigenère. It was not broken until 1863 although these days it is highly insecure and is now only useful as an interesting programming exercise. If you want to read up on it in full check out the Wikipedia article
The problem with the Caesar Shift Cipher is that each letter…
The phrase “convolution matrix” sounds a bit scary if you are not familiar with the topic but it is actually a very simple concept to understand and extremely powerful. The process is best explained with a diagram.
In future articles I will explore a few more of JIMP’s capabilities.
I have been working on a Node site for my photographs for an embarrassingly long time, adding small bits of…
Digital photos have embedded within their files various pieces of information about the image: the camera make and model, shutter speed and aperture, the date and time etc. This is called Exif data (an acronym for “Exchangeable image file format”) and can be read and displayed by suitable software. In this post I will show how to read Exif data using Python and the Pillow library.
I recently wrote an article on Pillow which you might like to read first.
Unfortunately Exif is not easy to deal with. It would be nice if the data consisted of a string of…
Pillow describes itself as “the friendly PIL fork”, PIL being the now-defunct Python Imaging Library. Fortunately Pillow is still very much alive and provides comprehensive image editing functionality.
You could in principle use it as the basis of a sort of lightweight Photoshop type application using perhaps Tkinter or PyQT, but its typical use case is for back-end processing, for example creating thumbnails and adding logos or watermarks to images uploaded to a website.
Despite its powerful and comprehensive abilities it is extremely easy to use and I will introduce what to most users are likely to be its most…
The electromagnetic spectrum covers a vast range of wavelengths and frequencies, only a tiny fraction of which is visible to the human eye. Wavelengths and frequencies are inversely proportional and the relationship between the two can easily be plotted. In this post I will write code in Python to do just that, using the actual colours each wavelength/frequency combination represents.
Wavelengths of electromagnetic radiation range from 1 picometre (one trillionth of a metre) to 100,000 km (about a quarter of the way to the moon). …
I am a content writer based in London, and I specialise in software development and related topics.