ECE 280/Imaging Lab 1
This page serves as a supplement to the first Digital Image Processing Labs for ECE 280. It has been updated for the Fall 2020 semester, including providing instructions for working on labs remotely.
Contents
Running MATLAB
MATLAB can be run remotely on the Duke Linux system, but it will generally be more convenient for you to install it on your own computer. All the documentation for this lab was written using MATLAB R2020a. It is likely that R2020b will also work, but neither that nor previous versions of MATLAB have been tested.
Installing MATLAB
MATLAB is free for Duke students. Follow the instructions in the Installation section of the EGRWiki page on MATLAB. Be sure to select the appropriate PRODUCTS when asked.
Using MATLAB Remotely
If you do not want to install MATLAB, you can use Duke's installation. You will first need to connect to the Duke Linux system using either MobaXterm (Windows) or XQuartz (macOS), making sure you correctly issues the ssh command to get graphics. Then simply type matlab &
to start MATLAB. More information is available at the page How To Get Work Done
Image Processing Toolbox
For this lab, there are a few commands you will need to learn (or remember):
imread('filename.ext')
will load an image into MATLAB. Depending on the image type, the return from this function may be a matrix of binary numbers (black and white images), an array of integers between 0 and 255 (grayscale images), or a three-layer matrix of integers between 0 and 255 (color images).image(matrix)
will display the contents of a matrix as viewed from above.- By default, the
image
command for a 1-layer matrix will assign colors based on a colormap that spans values from 0 to 255. Anything outside of that range will be clipped. - There are ways to change that, but you will not need to for this lab
- The
image
command for a 3-layer matrix will assign colors based on the first layer being the red component, the second layer being the green component, and the third layer being the blue component.- If the matrix is made up of floating-point numbers,
image
expects those numbers to be in the range [0, 1] - If the matrix is made up of unsigned integers,
image
expects those numbers to be in the range [0, 255] - If the matrix is made up of signed integers,
image
expects those numbers to be in the range [-128, 127]
- If the matrix is made up of floating-point numbers,
- By default, the
imagesc(matrix)
for a one layer matrix will display the contents of a matrix as viewed from above and will also map the minimum value to "color 0" and the maximum value to "color 255"; for a three-layer matrix it will work just likeimage
colorbar
will add a...colorbar to the right of an image to show the numerical values and colors associated with them. This is only useful for a one-layer image.colormap MAP
will assign a particular colormap. For this assignment, the most useful one is gray for grayscale images.axis equal
will tell MATLAB to display an item such that each direction has the same scale. For the imaging commands, this is useful in that it will make each pixel a square regardless of the shape of the figure window, thus preserving the geometry of an image.