University of Lincoln School of Computer Science CMP3108M – Image Processing
Week-2: Introduction to MATLAB and Image Processing Getting started with MATLAB
You should be able to find MATLAB on the Windows Start menu under All Programs. You are provided with a copy of ‘Matlab Tutorial.pdf’. This will serve as your MATLAB basic programming manual for the workshops in this semester, so please read it carefully. For today, work your way through Sections 2, 3, 6, 11, 12 and familiarise yourself with the basics.
Note: try implementing each command and understanding it before moving on to the next section. Ask the demonstrators for help if you have a problem with any of the sections.
Basic operations on images
You are provided with a copy of beginning section of the chapter 2 of the textbook ‘Digital Image Processing Using MATLAB’ called ‘DIPUM2E_Chapter02.pdf’. Read the chapter and try out examples that show how to work with the images. Also download the “SampleImages” zip file, un-compress the file, and save the files in your working folder. These are set of images that are useful for the workshop tutorials. Please note that the size of the images may be different from the examples provided in the book chapter.
Task
Write an m-file script to read the picture showing the aerial view of the Lincoln and displays the image. You can convert the colour image to gray-scale using the built-in function in MATLAB:
gray_image = rgb2gray ( colour_image );
Display the converted gray-scale image. You can check the pixel values with (x,y) coordinates of a pixel (as shown on the next page):
Select “Data Cursor” icon from the top menu
Click the mouse on the image
Now try to get the pixel value via the command window. You will need to provide the (x,y) coordinates for the pixel of interest. For example type in the command below and press enter:
gray_image (94,309)
Quiz: when addressing a pixel with an image, which one comes first? row (y) or column (x)
Now try changing the value of a pixel. For example try replacing a dark pixel (value of lower than 50, for example water area in the image) with a bright pixel (value of 255).
gray_image (y,x) = 255;
Display the modified image and see if you can spot the modified pixel.