DIP Lab Report 11

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

Digital Image Processing

Lab Report 11

Abdullah Fayyaz Abbasi


FA21-BEE-015 | BEE-6A

TO: Dr. Sajjad Ali Haider

14 May 2024

Department of Electrical & Computer Engineering


COMSATS University Islamabad, Wah Campus
CODE:
r=[0 1 7 5 1;
2 1 2 3 5;

4 4 4 1 3;

3 5 1 6 2;

1 0 3 3 2]

g=[1 2 7 1 1;

1 7 0 3 5;

4 6 5 5 6;

0 2 1 6 2;

2 4 1 3 4;]
b=[1 3 7 2 7;

2 7 2 2 0;

5 7 6 7 7;

3 2 1 6 2;
1 4 6 3 6;]

image=zeros(5,5,3);

image(:,:,1)=r;

image(:,:,2)=g;

image(:,:,3)=b;

a=im2double(image/7)

imshow(a);

xh=rgb2hsv(a);

imshow(xh);
Output:

CODE:
thresholding the intensity component of an HSI image to just two values can significantly alter
the appearance of the image, affecting contrast, segmentation, detail, and feature enhancement
depending on the chosen threshold value and the characteristics of the original image. If we set
the threshold value.
Output:
CODE (a):
R=[0.5 0 0.5];
G=[0.5 0.7 0];
B=[0 0.7 0.5];
image=zeros(3,1,3);
image(:,:,1)=R;
image(:,:,2)=G;
image(:,:,3)=B;
a=im2double(image)
figure;
imshow(a);
xh=rgb2hsv(a);
figure;
imshow(xh);
Output:

CODE (b):
H=[0.33 0.67 0];
S=[0.5 0.7 0.2];
V=[1 0.7 0.8];
image=zeros(3,1,3);
image(:,:,1)=H;
image(:,:,2)=S;
image(:,:,3)=V;
a=im2double(image)
figure;
imshow(a);
xh=hsv2rgb(a);
figure;
imshow(xh);
Output:

CODE (c):
R=[0.3 0.7 0.8];
G=[0.3 0.9 0.8];
B=[0.7 0 0.7];
image=zeros(3,1,3);
image(:,:,1)=R;
image(:,:,2)=G;
image(:,:,3)=B;
a=im2double(image)
figure;
imshow(a);
xh=rgb2ntsc(a);
figure;
imshow(xh);
Output:

CODE (d):
Y=[0.3 0.7 0.8];
I=[0.3 0.9 0.8];
Q=[0.7 0 0.7];
image=zeros(3,1,3);
image(:,:,1)=Y;
image(:,:,2)=I;
image(:,:,3)=Q;
a=im2double(image)
figure;
imshow(a);
xh=ntsc2rgb(a);
figure;
imshow(xh);
Output:

Code:
flowers_image = imread('peppers.png');
flowers_hsv = rgb2hsv(flowers_image);
intensity_component = flowers_hsv(:,:,3);
threshold_value = 0.5;
thresholded_intensity = intensity_component >= threshold_value;
figure;
subplot(1,2,1);
imshow(flowers_image);
title('Original Image');
subplot(1,2,2);
imshow(thresholded_intensity);
title('Thresholded Intensity Component');

Output:

Code:
spine_image = imread('spine.tif');
colormaps = {'jet', 'hot', 'cool', 'spring', 'summer', 'autumn', 'winter', ...
'parula', 'hsv', 'hot', 'gray', 'bone', 'copper', 'pink', 'lines',
'colorcube'};
num_colormaps = numel(colormaps);
figure('Name', 'Visualization with Different Colormaps');
for i = 1:num_colormaps
subplot(4, 4, i);
imshow(spine_image, colormap(colormaps{i}));
title(colormaps{i});
end
Output:

Code:
autumn_image = imread('autumn.tif');
autumn_hsv = rgb2hsv(autumn_image);
hsv_intensity = autumn_hsv(:,:,3);
autumn_yiq = rgb2ntsc(autumn_image);
yiq_intensity = autumn_yiq(:,:,1);
equalized_hsv_intensity = histeq(hsv_intensity);
equalized_yiq_intensity = histeq(yiq_intensity);
equalized_hsv_image = autumn_hsv;
equalized_hsv_image(:,:,3) = equalized_hsv_intensity;
equalized_hsv_image = hsv2rgb(equalized_hsv_image);
equalized_yiq_image = autumn_yiq;
equalized_yiq_image(:,:,1) = equalized_yiq_intensity;
equalized_yiq_image = ntsc2rgb(equalized_yiq_image);
figure('Name', 'Histogram Equalization Comparison');
subplot(2, 2, 1);
imshow(autumn_image);
title('Original Image');
subplot(2, 2, 2);
imshow(equalized_hsv_image);
title('Equalized HSV Intensity');
subplot(2, 2, 3);
imshow(equalized_yiq_image);
title('Equalized YIQ Intensity');
Output:
Code:
light_brown_hue = light_brown_hsv(1);
dark_brown_hue = dark_brown_hsv(1);
figure;
hold on;
light_brown_angle = light_brown_hue * 2 * pi;
light_brown_x = cos(light_brown_angle);
light_brown_y = sin(light_brown_angle);
plot(light_brown_x, light_brown_y, 'o', 'MarkerFaceColor', [0.8 0.6 0.4],
'MarkerSize', 10);
text(light_brown_x, light_brown_y, 'Light Brown', 'HorizontalAlignment', 'left',
'VerticalAlignment', 'bottom');
dark_brown_angle = dark_brown_hue * 2 * pi;
dark_brown_x = cos(dark_brown_angle);
dark_brown_y = sin(dark_brown_angle);
plot(dark_brown_x, dark_brown_y, 'o', 'MarkerFaceColor', [0.4 0.2 0.1], 'MarkerSize',
10);
text(dark_brown_x, dark_brown_y, 'Dark Brown', 'HorizontalAlignment', 'left',
'VerticalAlignment', 'bottom');
theta = linspace(0, 2*pi, 100);
circle_x = cos(theta);
circle_y = sin(theta);
plot(circle_x, circle_y, 'k--');
hold off;
axis equal;
title('Hues of Light Brown and Dark Brown Colors');
xlabel('Hue Angle');
ylabel('Hue Angle');

Output:
Code:
Peppers_image = imread('peppers.png');
Peppers_gray = rgb2gray(Peppers_image);
edge_image = edge(Peppers_gray, 'Canny');
imshow(edge_image);
Output:

Code:
x = imread('peppers.png'); % Replace 'your_image.jpg' with the filename of your image
xn = imnoise(x, 'gaussian');
average_filtered_image = xn;
for i = 1:3
average_filtered_image(:,:,i) = filter2(fspecial('average', [3 3]), xn(:,:,i));
end
wiener_filtered_image = xn;
for i = 1:3 % Loop over RGB components
wiener_filtered_image(:,:,i) = wiener2(xn(:,:,i), [3 3]);
end
figure;
subplot(2, 2, 1);
imshow(x);
title('Original Image');

subplot(2, 2, 2);
imshow(xn);
title('Image with Gaussian Noise');

subplot(2, 2, 3);
imshow(average_filtered_image);
title('Average Filtered Image');

subplot(2, 2, 4);
imshow(wiener_filtered_image);
title('Wiener Filtered Image');
Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy