COMPUTING II: Exercises related to Lecture/ Lab. session 1

Images and basic image processing

In a large number of cases, image data, whether meteorological images from a weather satellite, images from the Hubble telescope, or, simply, video "stills" from a surveillance camera, will be corrupted to some extent by noise. Image processing enables the effects of noise to be reduced by using computer algorithms to modify the image data.

Download the file noisy.dat to your network space.

Modify greyscle.c so that the file noisy.dat is loaded and displayed. Note the corruption of the image of a rather famous 17th century physicist by random noise.

Perhaps the most commonly used image processing technique is to "smooth" the data by taking the average of a number of pixel values. The simplest type of smoothing is 1 dimensional averaging (see below) where we take each pixel in each line of the image and add it to the value of its nearest neighbours in the same line. We then get the average and replace the original pixel value with the average.

1 dimensional averaging

Note that the values at the ends of the rows are not changed as these pixels do not have a neighbour on either side. (There are obviously better, though more complicated, methods of dealing with pixels at the edges of images). In addition, the average is always rounded to the nearest integer (pixel values must be integers).

 

1.1 Add a function to greyscle.c that carries out 1D averaging (think carefully about how to manipulate the array data).

1.2 Extend your program so that a two dimensional averaging or smoothing of the image is carried out. This is called a median filter. Your program should be capable of applying filters based on averaging up to nearest neighbours (i.e. involving a 3x3 sub-array of pixels), next nearest neighbours (5x5), (7x7) or (9x9) based on the choice the user makes.


Solution to Exercise 1

Coursework
Home