Assignment-0 DIP-CS406-Fal 2024
Assignment-0 DIP-CS406-Fal 2024
Fall 2024
Submitted to
Dr. Jameel Ahmad
Submitted By:
<Student Name, ID>
Note1: Upload the folder (with your ID as its name) containing your code files and assignment
report on LMS by the deadline.
Note 2: For Q1, the name of your MATLAB code file is ‘q1.m’, for Q2, the name of your
MATLAB code file is ‘q2.m’ and so on
Note 3: One of the good viewer is Irfanview. Download from http://www.irfanview.com/
or locally. (You can convert images from other formats to the pgm or ppm format by opening
them in Irfanview and then saving in the desired format)
%% 2) Copy im1 to im2_50 and add 50 to each pixel of im2_50 using for loop.
%displays and saves the image
1) (10 )Write a MATLAB code to read the files (owl.pgm and mecca06.pgm) and write these
files with the following names.
owl.pgm should be written as owl_Out.pgm
mecca06.pgm should be written as mecca06_Out.pgm
3) (10) Write MATLAB code to read the files owl.ppm in matrix m1 (it contains red, blue and
green color matrix). Similarly, read the file mecca06.ppm in matrix m2 (it contains red, blue
and green color matrix). Write these matrices in the files with the following names.
owl.ppm should be written as owl_Out.ppm
mecca06.ppm should be written as mecca06_Out.ppm
b) Make each pixel of the G matrix and B matrix of both the images to 0 (i.e., make the
G and B matrix of m1 to zero. Similarly make G and B matrix of m2 to zero). Write
the matrix (each comprising of red, green and blue matrix) of each image in a file
named owl_Red_out.ppm and mecca06_Red_out.ppm.
c) Make each pixel of the R matrix and B matrix of both the images to 0. Write these
three matrices of each image in a file named owl_Green_out.ppm and
mecca06_Green_out.ppm.
d) Make each pixel of the R matrix and G matrix of both the images to 0. Write the
matrix of each image in a file named owl_Blue_out.ppm and
mecca06_Blue_out.ppm.
e) Make each pixel of the R matrix to zero. Write the matrix of each image in a file
named owl_GreenBlue_out.ppm and mecca06_GreenBlue_out.ppm.
f) Make each pixel of the G matrix to zero. Write the matrix of each image in a file
named owl_RedBlue_out.ppm and mecca06_RedBlue_out.ppm.
g) Make each pixel of the B matrix to zero. Write the matrix of each image in a file
named owl_RedGreen_out.ppm and mecca06_RedGreen_out.ppm
h) Take the logarithm (log) of base 10 of each pixel of the three (red, green and blue)
matrices of the each images and save the matrices in the files (owl_Log_Out.ppm and
mecca06_Log_Out.ppm)
i) Generate the gray scale image of these colored images i.e., owl.ppm and mecca.ppm.
Take the average of pixels of these three matrices of each image and generate one
matrix. Later save this matrix in a file named owl_grayScale_Out.pgm and
mecca06_grayScale_Out.pgm
Report: Your report should contain your MATLAB code, the explanation of code/algorithm in
simple English, input images and output images.
If you have discussed (only discussed not copied) your assignment with any other student, then
write the name of your discussion partner in your report. The template of the assignment report is
given below with this assignment.
Code
<Write your code in italic>
Description of Code
<Describe you code/algorithm in simple plain English >
Result
<Describe the result of your code i.e., explain the output of your algorithm. Do also explain the output images that
are obtained by applying your algorithm/code to the input images.>
Input Images
<Paste your input images>
Q1
Output Image
<Paste your output images.>
Q1
Question 2
<Question Statement>
Code
<Write your code in italic>
Description of Code
<Describe you code/algorithm in simple plain English >
Result
<Describe the result of your code i.e., explain the output of your algorithm. Do also explain the output images that
are obtained by applying your algorithm/code to the input images.>
Input Images
<Paste your input images>
Q2 a) Q2 b) Q2 c) Q2 d) Q2 e)
Output Image
<Paste your output images.>
Q2 a) Q2 b) Q2 c) Q2 d) Q2 e)