0% found this document useful (0 votes)
6 views

Assignment 1

The document describes a Matlab assignment with 5 questions. Question 1 asks to write a function to modify pixel values of an image. Question 2 asks to randomly crop an image. Question 3 asks to call the functions from questions 1 and 2. Question 4 rewrites question 2 using matrix operations. Question 5 measures the runtime of questions 2 and 4 functions.

Uploaded by

aziz.sana2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Assignment 1

The document describes a Matlab assignment with 5 questions. Question 1 asks to write a function to modify pixel values of an image. Question 2 asks to randomly crop an image. Question 3 asks to call the functions from questions 1 and 2. Question 4 rewrites question 2 using matrix operations. Question 5 measures the runtime of questions 2 and 4 functions.

Uploaded by

aziz.sana2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1501441 Multimedia Technologies

Assignment #1
• Please work on this assignment by yourself. Do not get any help from your class colleague. Similarities
in solutions will be treated as cheating. If you have any problem just contact me.
• Each question will be graded ON-OFF. Either you get the question grade, or you will get a zero.
• 100% of the grade cover CLO2.
• Due date is 16-2-2024 by midnight.

For each question of the following, write each code in a separate file and name each file as follows
yourStudentID_QuestionNumber. In the last question, submit your answer in a word file. Submit all files
on blackboard. You should not use any operation of predefined function that we did not cover in the
slides.

1. [20 points] Write a Matlab function that takes three parameters, F, S, and O. F is a gray scale
matrix of any supported Matlab image class. S can be a double number in the range [0 1] or a
double matrix of the same size of F that contains double numbers in the range [0 1]. O is a string
that can be either ‘multiply’ or ‘add’. If S is a number, the function returns an image matrix that
has the same image class of F after adding or multiplying S to all pixels in the image. If O is
‘multiply’, S will be multiplied as is. If the operation is ‘add’, S should be converted to match F
class (as a gray scale) and then it will be added to F. The same should be done if S is a matrix but
the operation will be performed element wise. This function Should perform its operations using
loops. The function should perform all required error checking.

2. [20 Points] Write a Matlab function that takes gray image matrix F and 2 integer numbers R and
C. The function will return an image matrix after deleting R rows and C columns randomly from
the image. This function Should perform it operations using loops. You cannot use any of the
predefined functions in Matlab for image resizing or cropping. The function should perform all
required error checking. For this question, you need to generate unique random numbers
because you cannot delete the same row 2 times. Rand and randn may give repeated randome
numbers. use p = randperm(n,k) to return a row vector containing k unique integers selected
randomly from 1 to n inclusive.

3. [10 Points] Write a Matlab function that asks the user to input an image name, 2 integer numbers,
and an output image name. The function reads the image with the input image name using imread
and make sure that the image is loaded. The function then calls the function defined in the
previous question to perform the required image operation. Then, if the operation was successful,
the function saves the modified image to a file named as the output image name using imwrite.

4. [25 Points] Re-write Question 2 using victor (matrix) operations to perform the needed
operations.

5. [25 Points] Write a matlab script that runs the functions from questions 2 and 4 for 10 times each
on the rose_1024 image, [R,C]= (100,100), and measure the execution time of each run. Record
the execution time of each run in the following table and then calculate the average of the 15
runs.

Run number Runtime of the code in question 2 Runtime of the code in question 4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Average:

On average, which run is faster?

You might also like