3c72 Image Processing, Practical One - Basic Operations

5%, To be set 15/10/02, to be completed by 29/10/02.

1. Objective

The aim of this first practical is to provide an opportunity for you to use some of the basic image processing operations discussed in the first few lectures, in particular, pixel-wise operations. It also requires you to acquire images, eg on the laboratory workstations using the cameras available during the designated practical sessions, to use some of the functions available in MatLab to manipulate these, to output the results and to reflect and, where appropriate, comment on what you have done.

The exercise itself will be preceded by a brief introduction by the Teaching Assistants/Laboratory Demonstrators to image acquisition, to the location of some "canned" images and to MatLab. The libraries in MatLab are well suited to the exercises below and are extensively used for image processing.

Although the SUN cameras will acquire low fidelity colour images, this exercise is best carried out using grey-level imagery only. It is therefore best to grab-colour images and then use tools such as xv (or, of course, a suitable MatLab function) to convert to grey level images.

Finally, a word on image formats. When digital image processing and computer vision took off in the 1980s as the processing speeds and memory capacities required began to become available on (relatively) inexpensive workstations, the issue of image formats was one of considerable concern and the subject of much debate. Nowadays, however, a plethora of standard formats are readily available and many tools are provided in MatLab and, eg in xv, in Photo Editor, and in word processing systems such as Word, for converting between them. We shall therefore not discuss image formats further, although it must always be remembered:

Filters that convert between one format and another are not magical. If the formats between which an image is being converted do not match in resolution, accuracy etc, then the filter will use similar techniques to those discussed in the lectures and used in this exercise to interpolate or replicate data as required. Beware therefore of a potential loss in fidelity or the possible creation of artefacts on converting an image from one format to another.

2. Procedure

Carry out each of the steps listed below and write a brief report containing:

Your demonstrator and assistant for this practical is Ben Dias. Please click here to read some instructions prepared for you (and the masters students) regarding image capture and preparation, as well as a series of comments about miscellaneous technical issues of the practical.

3. Exercises

3.1 Image Acquisition

Acquire and store suitable grey-level images of a hand (for example, your own) and of a face (more amusing if it's someone else's). By "suitable", I mean under appropriate lighting and imaging conditions such that the hand and face fill a reasonably large proportion of the field of view, that detail within each image can be seen, for example of the vein structure on the back of the hand and of facial features, and that the images are not too dark (ie, above the noise level) without being too bright (ie, reaching the maximum signal level of the camera). In view of the exercises to be carried out, you might grab several examples of each image so that you can choose the one best suited to each exercise. For the hand examples, for use in a later practical you may also wish, without moving the camera, to take some images of the background against which you imaged your hand.

3.2 Grey-Level Transformation

Write a function (or use one supplied in MatLab) to subject one example of your hand and one example of your face images to a linear and to a non-linear grey-level transformation. In the former case, choose a suitable range of the original (source) image to be transformed, whilst in the latter case use the transformation:

I' = (I)g

with g in the range 0.5-1.0. This kind of non-linear transformation (gamma correction) is used in photography and to correct for the characteristics of acquisition or display devices. Note that for a CCD camera, g is approximately one, at least whilst the image intensity is within the dynamic range of the camera. A histogram of the image's grey-levels may be obtained by using the MatLab 'hist' function.

You may spot that xv contains a facility for doing just this. If you wish, use it to check your result, but do not use it as a substitute for the exercise as that would destroy the point of the example which is to practise by coding it yourself using MatLab.

If your images don't work well, try the jpeg example image of me (bernard0.jpg) or Charlie (charliegrey.tif) in my public_html directory. The former is a colour image and will need converting to a grey-level image first. Alternatively, try changing each colour channel separately or just have fun using the colour editor in xv.

3.3 Histogramming

(i)    Write a MatLab program for yourself that computes the histogram h(I) of an MxN image I and demonstrate that it works by comparing results obtained with your code to the histograms generated by the MatLab function for each of the two example images you chose above.

(ii)    Modify your code also to calculate the cumulative histogram, H(I), defined to be the number of pixels with grey-level or intensity less than or equal to I. Compute the cumulative histograms for the example images used in (i) above and compare to what may be obtained using MatLab functions. Comment on the form of the cumulative histograms obtained.

(iii)    Adapt your code to produce the histogram and cumulative histograms from part of an image defined by a rectangular window specified by the pixel co-ordinates of its top left and bottom right hand corners. Again illustrate its use on your example images and compare your results with what can be obtained using MatLab functions. Comment on the form of the cumulative histograms, in particular what happens to them near the maximum intensity, IU, or near I=255 as the case may be.

3.4 Histogram Equalisation

The histogram of  an image's grey-level distribution, h(I), when normalised by the number of pixels, MN, may be regarded as an approximation to the probability distribution of the image intesity p(I) = h(I)/MN, and similary H(I) used to approximate the cumulative probability distribution P(I). In order to obtain a uniform histogram, the grey level intensities in image I must be mapped into a different set, I'. If the histogram of I' is to be uniform over the range, I'L </= I' </=  I'U, the required mapping from an intensity level I to I' is:
        I'=I'L+(I'U-I'L)H(I)    .
Comment on the nature of this mapping, in particular when, in terms of the quantisation levels: (i) it is one-to-one, (ii) many-to-one,and (iii) one-to-many. Verify that the histogram obtained with this mapping is uniform. Comment on your results.

3.5 Producing an Image

Use the mapping above to produce the new image I'(x,y) from the original I(x,y), taking particular care when the mapping from I to I' is one-to-many and, in this case, assigning pixels from I at random to the appropriate quantisation levels in I'. Compare your results with what may be obtained by using a tool such as xv.

3.6 Histogram Manipulation

Repeat 3.4 and 3.5, but with the mapping     I'=I'L+(I'U-I'L)[H(I)]1/2  . Comment on the form of the histogram obtained for I' and on the appearance of the transformed image I'(x,y).

Reporting

It is recommended that Departmental or College PCs be used for report preparation as software available on them for document preparation is usually more extensive and more appropriate for this kind of task (eg Word) than that on the workstations. It also frees the workstations for more serious use by others. Image data should be included (in a suitable format; see above) in your report, using the facilities available, for example in Word. Whilst this can undoubtedly lead to satisfyingly pretty output, this is not the point of these exercises.

In fact, in general beware of labouring long and hard to produce a pretty report. There is a rapidly diminishing rate of return for such efforts. Evidence that the exercise has been completed and content of the report is much more important than presentation.

Bernard Buxton
October 2002.

Help Topics