Machine Vision Practical One - Basic Operations

5%, To be set 15/10/02, to be completed by 4/11/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.

The aim of the assignment is that you practise using these MatLab facilities or those provided for the exercises, or where necessary, write your own functions. Do not use ready made applications, eg in Microsoft Office, to do the job for you. That would defeat the point of the exercise and won't be of help to you later when you are asked to do things not available in off the self applications.

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 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 exercise 3.6, without moving the camera, 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. 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) and the images of Ben or Charlie (ben.tif and charlie.tif, respectively) in my public_html directory, or those indicated by the laboratory demonstrator. Some of these are colour images and will need converting to grey-level images first. Alternatively, try changing each colour channel separately or just have fun using the colour editor in xv.

3.3 Geometric Transformations

Select an area of detail on one of your face images and blow it up by a factor of two in each linear dimension. Do this using nearest-neighbour, bilinear and bicubic interpolation, using suitable functions from MatLab. Describe what differences you would expect to see in the different methods of interpolation. Are such differences visible in your example? Comment on their presence or absence. What happens if you blow up the image by a further factor of two or more in each linear dimension?

[If time allows.] Discuss how the interpolation techniques used here relate to those described in the MMAI lectures and assignments.

3.4 Image Warping

Subject one of your face images to a 45 degree shear on the x-axis by defining a suitable linear (affine) transformation of the image co-ordinates. Comment on whether you think it is necessary to use interpolation in order to compute the destination image in this case. Discuss what would have to be done for a 30 degree shear. Investigate whether there are any MatLab functions that you can use to help carry out such image shears.

[If time allows.] Use a combination of several 45 degree shears to carry out a 90 degree rotation. Think carefully about how many shears are needed. Use xv or functions provided in MatLab to check your results.

3.5 Manual Warping

Define a set of control points on one of your face images and use them to warp it in whatever way you please. There are MatLab functions which can be used for warping, but check how they work. The laboratory demonstrator has provided functions to help you with the control point placement and the warping. In particular, do the functions supplied by the demonstrator only work when you have enough control points to make the transformation determined or overdetermined? Will they work or not work if too few control points are used? Describe, as far as you can, what is happening during the transformation.

3.6 Image Subtraction

Subtract some of the background images taken for the hand examples from the example images. Describe the results obtained, commenting on the extent to which the background can be eliminated from the hand images by such means and on what you think affects this. If time allows, experiment to see if a threshold can be set in order to enable the hands in your images to be detected and their outline determined. Discuss the potential for application of such techniques as a means of detecting objects in a scene and for detecting object motion. Describe briefly what you think could be done to improve the reliability of object detection by this means.

3.7 Morphological Noise Removal

Investigate the use of simple morphological operations (dilation and erosion) for removing background noise from the subtracted images. Try this on both thresholded and non-thresholded images.

Reporting

It is recommended that PCs (eg as available in College clusters) 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. If desired, image data, either acquired images or results, may be transferred to PCs by ftp and then 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 and it can be much more efficient (for you) to print images directly from the workstations and include them in the report as separate pages, for example in the results section.

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