Resit Coursework Briefing

75 views 8:55 am 0 Comments February 28, 2023

MATH1143 Resit Coursework Briefing

Introduction

The resit coursework provides an opportunity to show that you have met the practical learning outcomes of the module.

If you have not submitted the coursework which was due in Term 2 of the 2021-22 academic session but you have been allowed a resit opportunity, then you may choose either of the following options for the resit coursework assignment.

If you have submitted the coursework which was due in Term 2 of the 2021-22 academic session but did not receive a passing grade and you have been allowed a resit opportunity, then you should choose the option that you have not yet attempted.

Now that you have familiarised yourself with MATLAB through the ‘Onramp’ introduction and the examples you have seen in class, you are ready to use it in the context of an engineering problem.

Option 1:     Modelling of the forces acting inside a bulk solids silo.

Option 2: Writing your own Matlab code to remove noise from a digital image.

Option 2:  Removing noise from digital images

Background

Digital images are displayed as a matrix of picture elements (pixels). When viewed from far enough away, the individual pixels are not visible but appear to form a continuous image. Digital images come in many formats (some compressed, some uncompressed) but they all contain the information necessary to generate the matrix of pixels that form the desired image. Figure 3 shows a section of an image that has been enlarged to the point where the individual pixels are visible.

Figure 3:  Enlarged section of a photo to show individual pixels

One way to store colour information in a digital image is to assign the intensity of red, green, and blue (RGB) of each pixel as an integer between 0 and 255, where 0 is no intensity and 255 is maximum intensity, allowing 256 different values. The total number of colour possibilities is therefore . (Note that other ways to store colour information also exist, but this is the one that will be used for the coursework.)

Colour digital images can be imported as a matrix and manipulated in software such as Matlab in to change, enhance or bring out selected features of an image. The images can be stored using a ‘stack’ of three two-dimensional matrix ‘layers’ where each matrix stores values the red, green and blue pixel intensities respectively. This makes up a three-dimensional matrix overall. Black & white images don’t require colour information, so they can be stored as a single two-dimensional matrix of grayscale intensity values.

Image noise reduction using spatial filtering

Sometimes digital images suffer degradation in the form of digital noise. This can result from a variety of sources such as electrical noise in the camera itself, noise introduced by digital transmission etc. Once an image has been degraded by noise some of the original information in the image is lost, but through restoration techniques it is sometimes possible to recover some of the image quality.

One way to attempt to restore an image is to consider each pixel’s value together with its neighbours. The pixel value is replaced with either the mean of itself and its neighbours (a ‘mean filter’) or the median of itself and its neighbours (a ‘median filter’). The size of the neighbourhood can be varied, as shown in Figure 4, and the neighbourhood size that achieves the best result can be selected. This type of processing is called a spatial filter.

pixel neighbourhood                    pixel neighbourhood

Figure 4:  Pixel neighbourhoods, highlighted yellow, for image filtering

Assignment

Using Matlab, develop an algorithm that implements a spatial filter which attempts improve the image quality of the following two given noisy images, which are available from the MATH11143 Moodle page:

• latte_noisy.bmp (black & white image)

• phonebox2_noisy.bmp (colour image)

The two files above are available from the course Moodle page in the assignment brief folder.

Note: you may not use any of the specialised image filtering toolbox functions in Matlab, such as imfilter() medfilt2(). Your code for performing the filtering operation must use the matrix elements themselves for the calculations, along with programming constructs such as ‘for loops’. Some other Matlab functions that you will find useful include:

• imread  to import images as a matrix into Matlab, for example:

               myImage = imread(‘latte_noisy.bmp’)

• imshow to show a Matlab matrix as an image, for example:

imshow(myImage)

• imwrite  to write a matrix as an image to a file, for example:

imwrite(myImage,’myImage.bmp’)

As a guide, the following questions should be addressed in your investigation:

  • Compare the effectiveness of median and mean filters in removing the noise from the given images (latte_noisy.bmp and phonebox2_noisy2.bmp.  Which works best in each case?
  • What is the best neighbourhood size for the filters in each case?
  • Why does it take a rather long time for Matlab to calculate the result?