Lab 1
Lab 1
Deliverable:
To gain the marks for this lab you will need to show me your Lab1 function running during the lab. The specification for this function is towards the end of this document. To get started quickly work through the Getting Started and Introduction to Image Processing in Matlab sections.
Getting Started
1. Make a new directory in which to do your work for this course. 2. Download the image text.tiff from http://www.syseng.anu.edu.au/~luke/cvcourse_files/images/text.tiff Save this image in your new directory. 3. Open Matlab from the Start>Programs menu. 4. Change to your new directory (use cd). 5. Type edit to open a new script file, and you are ready to start work. I suggest you do all your work in your script file.
Did you know: You can write multiple Matlab functions in the same file? This is helpful to keep your work together especially when working on large projects, to do this you will have to make the file a function. You can use the debugging features in the Matlab editor to jump between the local variable spaces when debugging your functions. Check 'Stop if Error' in the Breakpoints menu of the Matlab editor to activate the debugger on the next error. Note the different cursor in debugging mode. dbquit exits debugging mode. Remember to quit debugging mode before rerunning your code.
You can interactively crop an image using imcrop(im_grey); Try this. For this lab exercise I would like you to crop the image to a specified region containing only the 2nd letter. Do this with im_grey = im_grey(150:270, 280:400); Examine the intensity profile of im_grey improfile(im_grey); Threshold im_grey im_bin = imgrey>0.5; The object we are interest in is the text, since we have defined binary objects to be 1s and the background to be zero we need to invert the image im_bin = 1 im_bin; % inverts the binary image.
You can find the coordinates of the points in this object using find. Type help find to learn about this function. Write a line of code using find that returns the x and y values of all the points in the object. Now youre ready to get to work on the assessable task.
function [moments, orientation] = find_moments(I_bin); % Calculates the 0th , 1st and 2nd moments and orientation of % the binary image I_bin and % returns: % moment.M = 0th moment (area) % moment.Mx = 1 st moment (x-coordinate of centroid) % moment.My = 1 st moment (y-coordinate of centroid) % orientation = orientation When writing find_moments you will find it useful to refer to the lecture notes on binary moments. You can access these online from www.syseng.anu.edu.au/~luke/cvcourse.htm. You might like to try your code on other letters in text.tiff as well, or to construct some artificial data to test your system.
Experiment with impixel, improfile, histeq, colormap, bwmorph, bwlabel, Type help <functio n> to see the specs for the functions then see if you can implement them. I suggest trying the following quick exercises: Use bwlabel to label a point in a binary image Experiment with dilation, erosion, opening and closing using bwmorph, try and simulate the results presented in lectures.