In this course the Matlab programming language will be used to complete the programming assignments. It is not a prerequisite of the course to know Matlab. Students will be given the opportunity throughout the semester to become sufficiently familiar with this language.
Students can always refer to the background
materials available on the course page:
http://www.cs.brown.edu/courses/cs143/BackgroundMaterial.html.
In this short assignment, you will learn how to access Matlab on the Brown CS network, and then you will experiment with displaying images in Matlab.
DUE DATE: Monday, September 10, in class.
This purpose of this tutorial is to give you a brief introduction to Matlab (http://www.mathworks.com/) to make it easier for you to implement the assignments for CS 143. You might also want to use Matlab for your final project. There are several reasons why we think it is worthwile getting familiar with it: First of all, Matlab will most likely save you quite a bit of time, although it may not seem like it initially. Also, Matlab is a standard software tool that's used in research and in industry, so it's a good thing to know it. As a bonus, several other CS courses, e.g. CS 195-5 and CS 224, use it, too.
There's an abundance of information and Matlab tutorials on the Web. If you don't like any particular one, just go to Google and you'll surely find something useful. A few good links are:
However, a lot of these tutorials are quite lengthy and include more detail than you will probably need. Hence our summary here:
Everyone with a CS account has access to various versions of Matlab on all of the Linux systems. By now, everyone should have a CS account, but if you don't have one, please email the TA pyadolla@cs.brown.edu or moldovan@cs.brown.edu.
If you prefer to work on your own computer, you can get Matlab from CIS for the most important platforms:
However, all of these only work while you are on the campus network, because they need to access a license server. If you want to use these Matlab versions from outside the campus, you will most likely have to get onto the campus network using VPN. You're entirely on your own on this though.
To start Matlab, you use the following command:
$ matlab65 &
Please make sure you are using the latest version of Matlab.
If you dislike the unfortunately rather slow and buggy GUI you can run the command line mode using:
$ matlab65 -nodesktop &
The directory you are in when you run Matlab will later be important,
because Matlab will automatically load any .m files (Matlab
programs) that are in your current directory. Nevertheless, if you
started from the wrong directory, you can either change the directory
using the GUI or you can use cd <directory>. Other Unix-like
shell command such as ls and pwd are supported as well.
To quit Matlab, type:
>> quit
The Matlab GUI comes with a pretty extensive help system. If you don't like GUIs or you just need to quickly look something up, you can use the following commands:
>> help <function_name>and for searching
>> lookfor <keyword>
Try typing in "help sum" and "lookfor logarithm". The lookfor
command may take around 10 seconds to finish.
Begin by copying the following file to your working directory: /course/cs143/asgn/0/cit.png. Start Matlab in the same directory.
To load the image into variable img, type the following and press ENTER:
img = imread('cit.png'); % Read a PNG image
In case you forgot to type the semicolon, you may have had the surprise of a
long printout. In Matlab, a semicolon at the end of a
statement means that Matlab will not display the
result of the evaluated statement. If the ";" is omitted then Matlab will
display the result. This is also useful for printing the value of
variables.
The image is stored in a matrix of size 231 x 300. To see that, type:
size(img)
Now to display the image, type:
figure
imagesc(img) % Display it as gray level image
colormap gray;
colorbar % Turn on color bar on the side
pixval % Display pixel values interactively
Your task is to find the exact minimum, the maximum and the mean of the pixel values of the CIT image using Matlab. The color bar might give you an idea of the pixel range.
HINT: Use your intuition and also the help and lookfor commands. No for loops are necessary.
At the beginning of the class on Monday, September 12, hand in a piece of paper showing the pixel range and the mean, what you did to find find them and a printout of the figure containing the image and the color bar. Don't forget to include your name and your login.