User:Inconspicuum/Physics (A Level)/Digital Processing

As we have already seen, a digital image consists of pixels, with each pixel having a value which represents its colour. For the purposes of understanding how digital images are manipulated, we are going to consider an 8-bit grayscale image, with pixel values ranging from 0 to 255, giving us 256 (28) levels of grey. 0 represents white, and 255 represents black. This is the image we are going to consider:

The image consists of an edge, and some random noise. There are two methods of smoothing this image (i.e. removing noise) that you need to know about:

Mean Smoothing
In order to attempt to remove noise, we can take the mean average of all the pixels surrounding each pixel (and the pixel itself) as the value of the pixel in the smoothed image, as follows:

This does remove the noise, but it blurs the image.

Median Smoothing
A far better method is, instead of taking the mean, to take the median, as follows:

For this image, this gives a perfect result. In more complicated images, however, data will still be lost, although, in general, less data will be lost by taking the median than by taking the mean.

Edge Detection
We can detect the positioning of edges in an image using the 'Laplace rule', or 'Laplace kernel'. For each pixel in the image, we multiply its value by 4, and then subtract the values of the pixels above and below it, and on either side of it. If the result is negative, we treat it as 0. So, taking the median-smoothed image above, edge detection gives the following result: