Problem 1. Basics
3 9 5 1 0 1 0 1
4 25 4 3 0 1 1 0 InputA=63 13 23 9andB=0 0 0 1.
6 32 77 0 1 1 0 1
12 8 6 1 0 1 0 0
- (i) Point-wise multiply A with B and set it to C.
- (ii) Calculate the inner product of the 2nd and 3rd row of C.
- (iii) Find the minimum and maximum values and their corresponding row and column indices in matrix C. If there are multiple min/max values, you must list all their indices.
In your report include all the outputs generated by your code.
Problem 2. Simple image manipulation
- (i) Download any color image from the Internet or use one of the given images. Read this image and call it A.
- (ii) Transform the color image to gray-scale. Verify the values are between 0 and 255. If not, please normalize your image from 0 to 255. Call this image B.
- (iii) Add 15 to each value of image B. Set all pixel values greater than 255 to 255. Call this image C.
- (iv) Flip image B along both the horizontal and vertical axis. Call this image D.
- (v) Calculate the median of all values in image B. Next, threshold image B by the median value you just calculated i.e. set all values greater than median to 0 and set all values less than or equal to the median to 1. Name this binary image E.
Include all images A-E in your report. Try to fit at least 4 images in a page.
Problem 3. Histograms
Histograms1 are a great statistical tool to analyze the distribution of intensity values in an image. In this problem, you have to write a Python function with the following specifications:
- Write a function named compute norm rgb histogram that computes the RGB color his- togram.
- Use 32 bins for each color channel (i.e. Red, Green and Blue), spaced equally between 0 and 255. This should result in a 32-length vector for each channel.
1You can read more about Histograms here.
2
- One input (RGB/color image) and one output (1 x 96 vector).
- Normalize the histogram of each color channel (so that it sums to 1), then concatenate the three histograms together (in the order R, G, B) to make a combined histogram of length 3×32 = 96.
- Do not use Python inbuilt histogram function. You may use loops if necessary.
- Call the function and plot the final combined, normalized histogram for the image geisel.jpg.
Make sure the plot is labeled correctly. Show your plot in the report.
Problem 4. Chroma Keying (6 points)
Chroma keying is used for extracting the foreground from images, with the background typically being a green screen. In this problem, you have been provided 2 images: travolta.jpg and dog.jpg. Write a script to extract the foreground from either image and overlay the foreground on a different background of your choice. In your report you should include for each of the images:
- (i) A binary image showing the foreground mask, i.e., all foreground pixels set to 1 and all background pixels set to 0.
- (ii) An image with the background pixels set to 0 and the foreground pixels set to their original values.
- (iii) An image with the foreground overlayed on a background of your choice.
Problem 5. Upsampling and downsampling (10 points)
Sampling is a technique that enables you to resize the image to desired resolution. Different interpolation techniques can be used for sampling. In this question, you will perform experiments on different interpolation methods for upsampling and downsampling (Hint: you can use resize function for both upsampling and downsampling).
- (i) List (and describe in a short paragraph) 3 interpolation methods.
- (ii) Select 3 color images and downsample using the different methods with the 3 ratios below. What differences do you observe? Which interpolation method do you think works best?
- Dowsampling ratio: 0.3, 0.5, 0.7
- Please include the images in the report. Crop small regions to compare if necessary. You
should have 27 images (3 images ∗ 3 methods ∗ 3 ratios).
- (iii) Repeat the previous step, but this time use upsampling with the ratios below. What differ-
ences do you observe? What interpolation method works best? • Upsampling ratio: 1.5, 1.7, 2
• Please include the images in the report. Crop small regions to compare if necessary.
- (iv) Using 3 color images, downsample the images with scale 0.1 and upsample back to the original size, using all combinations of the three chosen interpolation methods. Which interpolation combination do you think works best to reconstruct the original image?
3




