Focus: basics of Matalb and image processing.
1. [4 points] A CCD camera chip of dimensions 10×10 mm, and having 4096 x 4096 sensor elements, is
focused on a square, flat area A, located 70 cm away. Assume each sensor element produces one
pixel in the output digital image. How many pixels per mm of the area A will this camera be able to
produce? The camera is equipped with a 35-mm lens. (Hint: f = 35 mm, z = 10 mm, see Fig. 2.3 from
the textbook). [adapted from the textbook Gonzales Q2.5]
2. [7 points – one for each answer] Write Matlab code to do the following:
a) Read the image ‘okanagan.jpg’ into a variable I1 (image can be downloaded from Connect).
Display the image on the screen.
b) Display the Red, Green, and Blue channels in three additional figure windows (now you
should have four images shown: the original and its three RGB channels). Make sure the title
shows the channel name.
c) Convert the image to grayscale. Save the output in the same variable I1. Show the new
image I with the title “I1”.
d) Display the size of I1 as: “The image I1 has … rows … of column. (Replace … with a value
computed by Matlab. You will need to find a Matlab function to format text and another to
display text on the console).
e) What is the class of I1? (Use whos or check the workspace. Write the answer as a comment
in your code).
f) Display the maximum and minimum pixel intensities in I1 as “Gray level range in I1: … to …”.
g) Create a new grayscale image I2 from I1 with gray level multiplied by 4. Show I2 and display
the max and min pixel values again as “Gray level range in I2: … to …”.
3. [4 points] Read the ‘cameraman.tif’ image into I2. Then, insert I2 into the bottom left corner of I1
you obtained from Q2(d) above so that the out image I4 looks like the one below. Also show I4 with
a suitable title. (Hint: use the size function and the (:) operator to determine the range).
merging two images
4. [5 points] Using the grayscale image I1 you had in Q2(d) above, write code to separate the
foreground (mountains, fields and lake) from the background (sky). The desired output is a new
grayscale image I4 from I1 with a black sky! You can do this by creating I$ such that pixels with
values above 175 (or another suitable value) are set to 0. Show the result with a title “I$:
Background (sky) removed!” (See output below)
Solve Q1 in a text file. Solve Q2 to Q4 in one Matlab program (or in three separate programs if
you prefer to do that). Submit everything as one zip file to Blackboard Connect. Note that you
can resubmit an assignment, but the new submission overwrites the old submission and receives
a new timestamp.
I3: Background (sky) removed!