The binary system
The binary system uses 2 digits - 0 and 1.
The 0s and 1s that make up binary numbers are called binary digits. A single binary digit it called a bit.
A byte = 8 bits
The number of bits in a string (what a file on your computer stores the data as) determines how many alternatives that string can code for.
The number of alternatives doubles with each additional bit, so:
Number of alternatives = 2^number of bits
Number of bits = log2(number of alternatives)
When an image is stored on, for example, a digital camera, each pixel is represented by a binary number
These numbers are stored in an array.
The numbers are arranged so the location of a number in the grid is the same as the location in the photo of the pixel it describes.
The valule of the binary number gives the colour (or shade of grey) of the corresponding pixel.
In coloured images, each pixel can be describe by 3 binary numbers (one for each of the primary colours of light).
The length of the binary numbers used depends on how many colours are needed.
Changing contrast and brightness
Multiplying every pixel value by the same amount will increase contrast.
A higher value represents a darker shade of grey. If we multiply every value by 3, then higher values will become much darker, and lower values will become darker, but not by as much. This increases contrast in the whole image.
Adding a fixed value to every pixel value will change the brightness.
If you add 50 to every pixel value, and a higher number results in a darker shade, then every pixel will become darker. The contrast hasn't changed, but the overall brightness has.
You can also do this to increase brightness.
Adding false colour
The values that are used to represent shades and colour in an image can be made to represent shades and colours in different ways.
A higher number can result in a darker shade or a lighter shade. It can result in a different colour too.
You can map the numbers to mean something specific.
The numbers can be used to create certain colours, for example, '5' could mean orange, whilst '6' means purple.
This is adding false colour, and it is usually used to highlight certain features.
Reducing noise and finding edges
Noise is unwanted interference affecting a signal. It is represented as bright or dark spots in an image.
To get rid of this noise, you replace each pixel with the median of itself and the eight pixels surrounding it.
This removes any high/low values.
To work out if something is in your image, finding edges can be useful.
To do this, you multiply a pixel by 4, then subtract the value of the pixels immediately above, below, to the left, and to the right of it.
This causes any pixel not on an edge to go black, leaving you with just the edges.
This is known as the Laplace Rule.