Uploaded by mahnoor07mustafa

LAB MANUAL

advertisement
Department of Software Engineering
Digital Image Processing
Lab Manual
SUBMITTED TO:
Dr. Mehreen Sirshar
SUBMITTED BY:
Mahnoor Javaid
(2020-BSE-015)
Mahnoor Mustafa
(2020-BSE-051)
CLASS:
BSE V
LAB # 2
Task 2:
Generate a matrix of size 200x200 pixels using “ones” function and apply the
following transformations. F(x, y) = F(x, y)*(-1) ^ (x + y); where “x”, “y” is
the index for row and column respectively and show the results.
Task 3:
a. Create a 200x200 matrix of ones
b. Pad 4 pixels wide border of zeros across each side of it, such that its order
will become (4+200+4) x (4+200+4) = 208x208. As shown in the figure
below.
Task 4:
Generate an RGB image in Figure 4 and 5.
a. size = 200 x 200 pixels,
b. Image type = rgb
Task 5:
a. Create an Image using zeros function of size RxC, and at its each pixel (X,
Y) store a value, that is Euclidean Distance from the center (R/2, C/2)pixel,
of the image, to the current pixel (X,Y).
b. After Calculating the distance apply this Threshold on the above image.
“min(R, C) / 4” to convert it to a binary image. i.e. bw0 = f < min(R, C)/4
and bw1 = f > min(R, C)/4, where “f” is the image from “part a”.
Task 6:
a. Read a colored image using “f = imread(‘image.jpg’); ” command.
b. Convert the image to gray scale using “fgray=rgb2gray(f)” command,
convert this image matrix in part to data type “double” like and divide it
by 255. i. e. fd = double (f) , and display normalized(0 -> 1) image. i. e.
imshow(fd, []).
c. Create a new image “fnew” from “fd” by multiply “fd” with a constant
value 0.33/255 and display it.
Task 7:
Interpolation and Decimation.
a. Decrease the gray level resolution of the image “fd” from previous question,
and reduce it to 128, 64, 32, 16, 4, 2 (or 7, 6, 5, 4, 3, 2, 1 bit per pixel) gray
levels and show the results.
b. Decimate the image “fd” from the previous question to decrease its special
resolution by factor 2, 4, 8.
c. Interpolate the image from result of (b) to increase its special resolution by
factor 2 and 3. Such that new image have size 2Rx2C and 3Rx3C if previous
is of size RxC.
d. Use “imresize” function to increase the resolution from the result of (b),
using bilinear interpolation. Use MATLAB help to learn about the syntax of
this function.
LAB # 4
Task 1:
a. Read a colored image. Convert the image to gray scale. Display the image.
b. Study “imrotate” command and rotate the image by 45 degrees using
bilinear interpolation.
c. Study the command of “imadjust”. Now adjust the gray levels of the
image. E.g. g=imadjust(f,[0.5 1],[0.9 0]); % gray value 0.5 is mapped to
0.9 and gray value 1 is mapped to 0 in the above statement.
d. Use “imadjust”. Now adjust the gray levels of the image. And set the
gamma less than 1. E.g. g=imadjust(f,[0.3 0.8],[0 1], 0.5); % gray value
0.3 is mapped to 0 and gray value 0.8 is mapped to 1 in the above
statement.
Task 2:
Study histogram equalization and perform histogram equalization to enhance
the grayscale image from Q1.
a. Calculate the histogram of the image and show it using “stem” command.
(don’t use MATLAB function to calculate histogram).
b. Calculate probability density function (PDF) from the histogram and
“stem” it. i. e. pdf = H/(R*C). Where H is the Histogram.
c. Calculate cumulative PDF and “stem” it. i. e. cdf = cumsum(pdf);
d. Multiply the Cumulative PDF with 255 to find the transformation function.
And stem it.
e. From the transformation function, replace the gray levels of the image to
create contrast enhanced (histogram equalized) image.
f. Display the enhanced image.
LAB # 5
TASK 1:
Read a colored image. Convert the image to gray scale. Display the image.
a) Study “imcrop” command and crop the image.
b) Study “imhist” function to create the histogram of the image and plot it.
c) Study “histeq” function and perform histogram equalization to enhance
the grayscale image.
d) Study “adapthisteq” function to perform adaptive histogram enhancement
and use ‘rayleigh’ ‘Distribution’.
e) Study “imhistmatch” and perform histogram matching of one grayscale
image with other grayscale image.
TASK 2:
TASK 3 I:
In previous class you have learn how to perform Mask
Processing/Filtering/2D Convolution. Revise these basic concepts and
techniques and apply the following operations.
a) Create a 3x3 averaging mask using ones function, i.e. msk1 =
ones(3,3)/(3*3);
b) Study “padarray” function, and perform zero padding and create padded
image (So that we will be able to apply the filter on the whole image
including border pixels).
c) Apply (Convolve) these masks on the padded grayscale image to filter it
and display the results.
TASK 3 II:
a) Crop a sub-image from the mask processed image using vector notations to
skip padded border.
b) Create a 7x7 averaging mask using ones, i.e. msk2 = ones(7,7)/(7*7); and
also apply it on the grayscale image and discuss witch one have better
results?
Download