Princeton has a site license of Matlab, so you can install it on your own machine - instructions are here.

Alternatively, Matlab is available on several OIT machines (look here for details). You should be able run it remotely from any Unix workstation.

Read through the following for a basic introduction to Matlab:

- A short Matlab introduction
- The demos accessible by typing "demo" within Matlab.

Work through the following tasks using an image of your choice. You do not need to submit any results, but make sure you are comfortable doing the following:

- Read an image into a variable.

"help imread"**Hint #1:**

Use single quotes around the filename.**Hint #2:**

Ending a command with a semicolon supresses printing the result.**Hint #3:**

- Display the image.

"help imshow"**Hint:**

- Convert the image to grayscale.

"help rgb2gray"**Hint:**Note: if your version of Matlab doesn't have the

`rgb2gray`function, download rgb2gray.m. Place this in your working directory, and it should be auto-loaded by Matlab. - Convert the grayscale image to floating point.

"help im2double", and be aware of the difference between**Hint #1:**`im2double(img)`and`double(img)`.

**Hint #2:**`imshow`is able to also display floating-point images.

- Plot the intensities along one scanline of the image.

Extracting a part of a matrix is done by**Hint #1:**matrix2 = matrix1(row_min:row_max,col_min:col_max);

`row_max`or`col_max`may be "end" to indicate the last element.

Just a ":" is equivalent to "1:end".

BIG WARNING: indices in Matlab are 1-based (not 0-based as in C).**Hint #2:**

"help plot"**Hint #3:**

- Store the width and height of the image in variables "width" and "height".

"help size"**Hint #1:**

Functions in Matlab may return multiple values. You can get at the values using the notation**Hint #2:**[var1, var2] = func(x)

In Matlab, the number of rows is the first dimension and the number of columns is the second.**Hint #3:**

- Write a pair of nested "for" loops to set a grid of every 10th pixel
horizontally and every 20th pixel vertically to 0.

"help for"**Hint #1:**

"start:increment:stop"**Hint #2:**

- Create a function "maxrow" that takes a matrix and a row index and returns
the brightest pixel in the given row. Store the function in a file called
"maxrow.m" so that Matlab loads it automatically when you call the function.

"help function"**Hint #1:**

Matlab has many built-in functions that operate on entire vectors or matrices. There might be one to compute the maximum...**Hint #2:**

- Write the modified image back to a new file.

"help imwrite"**Hint #1:**

**Hint #2:**`imwrite`assumes that intensity ranges of uint8 and floating-point pixels are [0, 255] and [0.0, 1.0], respectively.

If you get stuck on any of these, ask for help on piazza.