Professional Documents
Culture Documents
Digital Image Processing: Lab Report # 04
Digital Image Processing: Lab Report # 04
LAB REPORT # 04
Submitted To:
Submitted By:
Wajeeha Anum
Reg No:
17-CS-077
Section:
“A”
Lab #04
Objectives:
• To study the Image Enhancement Basics
• To Observe the variation of image contrast and intensity using a MATLAB Simulation
• To enhance images using gray level transformations
Software tools:
• Matlab
Theory:
Enhancing an image provides better contrast and a more detailed image as compare to non-
enhanced image. Image enhancement has very applications. It is used to enhance medical images,
images captured in remote sensing, images from satellite. The transformation function has been
given below
s = T (r)
Where r is the original gray level of a pixel and s is the resulting gray level after processing. T is
a transformation function that maps each value of r to each value of s. Image enhancement can be
done through gray level transformations, which are discussed below.
Procedure:
Task 01:
Why were we required to use I+1 when performing the Identity transformation instead of just I?
Answer:
We use I+1 to stay in bound otherwise we will get an error (Array indices must be positive integers
or logical values) so that is why we use I+1 when performing identity transformations in matlab.
Task 02:
How can we show that the adjusted image and the original image after applying Identity
transformation are equivalent?
Code:
After applying the identity transformations, we can say that the image is equivalent to the
original image’s complement, we can take the complement of original image and if we compare
that with the adjusted image, they will be equivalent.
Task 03:
How did we create the negative transformation function without using built-in command?
Code:
We used the following commands for creating negative transformations of an image without using
built in command:
Output:
Task 04:
Why does the log-transformed image display the hidden detail in the moon.tif image, but the
brightened image does not?
Solution:
This is because during log transformation, the dark pixels in an image are expanded as compare to
the higher pixel values. The higher pixel values are kind of compressed in log transformation. This
result in following image enhancement. If we brighten up the image then the effect is removed
because all of the pixels are brighten up so we cannot see those hidden details here is the output:
Output:
Task 05:
How does the shape of the curve for n-root function change if we were to use a different value
for n? Show for n=2, n=4, n=8.
Code:
n=2:
Output:
n=4:
Output:
n=8:
Task 06:
Write MATLAB Code to perform all gray level transformations studied in this lab on
“cameraman.tif” and submit codes along with results.
Solution:
Identity Transformation:
Code:
x = uint8(0:255);
plot(x); xlim([0 255]); ylim([0 255]);
I = imread('cameraman.tif');
I_adj = x(I + 1);
figure, subplot(1,2,1), imshow(I), title('Original Image');
subplot(1,2,2), imshow(I_adj), title('Adjusted Image');
Output:
Log Transformations:
Code:
I = imread('cameraman.tif');
I_log = uint8(y(I + 1));
subplot(2,2,2), imshow(I), title('Original Image');
subplot(2,2,3), imshow(I_log), title('Adjusted Image');
I_br = imadd(I,100);
subplot(2,2,4), imshow(I_br), title('Original Image Scaled');
Output:
Power Transformations:
Code:
x = 0:255; n = 2; c = 255 / (255 ^ n);
root = nthroot((x/c), n);
figure, subplot(2,2,1), plot(root), title('2nd-root transformation'), axis tight, axis square;
I = imread('cameraman.tif');
I_root = uint8(root(I + 1));
subplot(2,2,2), imshow(I), title('Original Image');
subplot(2,2,[3 4]), imshow(I_root), title('Nth Root Image');
Output:
Conclusion:
In this lab we learned about basics of matlab transformations, we used matlab image toolbox to
perform different transformation operation on images and we understood their working and
benefits.
======================================================