# Homework 1 ECE 253 Digital Image Processing

\$30.00

5/5 - (1 vote)

## Problem 1. Basics (3 points)

Input A =

3 9 5 1
4 25 4 3
63 13 23 9
6 32 77 0
12 8 6 1

and B =

0 1 0 1
0 1 1 0
0 0 0 1
1 1 0 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 4th 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.

## Problem 2. Simple image manipulation (5 points)

(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 (6 points)

Histograms1 are a great statistical tool to analyze the distribution of intensity values in an image.
In this problem, you have to write a MATLAB/Python function with the following specifications –
• Write a function named compute norm rgb histogram that computes the RGB color histogram.
• 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.

• One input (RGB/color image) and one output (1 x 96 vector).
• Concatenate the three histograms together (in the order R, G, B) to make a combined histogram of length 3 x 32 = 96. Once you have computed the combined histogram, normalize
it so that it sums to 1.

• Do not use MATLAB/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 matlab script to extract the foreground from either image and overlay the foreground on a

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) What are the interpolation methods you can find? (Please list 3)
(ii) How does each of the method work? (Please describe the method in 1-3 sentences)
(iii) Please select 3 color images and downsample using different methods. What are the differences
you can observe visually? Which interpolation method do you think to work better?

• Dowsampling ratio: 0.3, 0.5, 0.7
• Please include the images in the report. Crop small regions to compare if necessary.
(iv) Please select 3 color images and upsample using different methods. What are the differences
you can observe visually? Which interpolation method do you think to work better?

• Upsampling ratio: 1.5, 1.7, 2
• Please include the images in the report. Crop small regions to compare if necessary.
(v) Please select 3 color images. Downsample the images with scale 0.1 and upsample to original
size. Which interpolation combination do you think to work the best?