0% found this document useful (0 votes)
4 views19 pages

"C:/Users/Naval/Onedrive/Desktop/Anime-Night-Sky-Illustration - JPG" 1 3 1 'Original Image' 1 3 2 'Grey Image' 1 3 3 60 'Grey Shade'

The document contains a series of MATLAB experiments focused on image processing techniques, including reading, displaying, and manipulating images. Various operations such as converting to grayscale, combining images, filtering, and applying morphological operations are demonstrated. Additionally, histogram analysis and contrast enhancement for both color and grayscale images are included.

Uploaded by

22embit013
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)
4 views19 pages

"C:/Users/Naval/Onedrive/Desktop/Anime-Night-Sky-Illustration - JPG" 1 3 1 'Original Image' 1 3 2 'Grey Image' 1 3 3 60 'Grey Shade'

The document contains a series of MATLAB experiments focused on image processing techniques, including reading, displaying, and manipulating images. Various operations such as converting to grayscale, combining images, filtering, and applying morphological operations are demonstrated. Additionally, histogram analysis and contrast enhancement for both color and grayscale images are included.

Uploaded by

22embit013
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/ 19

EXP-2

a=imread("C:\Users\naval\OneDrive\Desktop\anime-night-sky-illustration.jpg");
subplot(1, 3, 1);
imshow(a);
title('Original Image');
j=rgb2gray(a);
subplot(1, 3, 2);
imshow(j);
title('Grey Image');
subplot(1, 3, 3);
jcolormap=coolcolormap(60);
imshow(jcolormap);
title('Grey shade');
Output-
EXP-3

a=imread("C:\Users\naval\OneDrive\Desktop\Plumeria -8.jpg");
subplot(1, 3, 1);
imshow(a);
title('First Image');
b=imread("C:\Users\naval\OneDrive\Desktop\56767fb3-5b16-4e60-9083-202890c72a50.jpg");
subplot(1, 3, 2);
imshow(b);
title('Second Image');
c=imadd(a,b);
subplot(1, 3, 3);
imshow(c);
title('Combined Image');

Output-
EXP-3.1

a=imread("C:\Users\naval\OneDrive\Desktop\Plumeria -8.jpg");
imshow(a);
xlabel('First Image');
figure(0);
b=imread("C:\Users\naval\OneDrive\Desktop\56767fb3-5b16-4e60-9083-202890c72a50.jpg");
figure(1);
imshow(b);
xlabel('Second Image');
c=imadd(a,b);
figure(2);
imshow(c);
xlabel('Combined
Images');
subplot(3,2,2);
imshow(b);
subplot(3,2,3);
imshow(a);

Output-
EXP-3.2

a=imread("C:\Users\naval\OneDrive\Desktop\Plumeria -8.jpg");
figure(1);
imshow(a);
xlabel('Original Image');
b=rgb2gray(a);
figure(2);
imshow(b);
c=imadd(b,100);
imshow(c);
xlabel('Final Output');
subplot(3,2,1);
imshow(a);
subplot(3,2,2);
imshow(b);
subplot(3,2,4);
imshow(c);

Output-
EXP3.3

img = imread("C:\Users\naval\OneDrive\Desktop\Plumeria -8.jpg");


hsv_img = rgb2hsv(img);
figure;
subplot(1, 2, 1);
imshow(img);
xlabel('Original RGB Image');
subplot(1, 2, 2);
imshow(hsv_img);
xlabel('HSV Image');

Output-
EXP-5.1

k = imread("C:\\Users\\naval\\OneDrive\\Desktop\\f44b7b24-1549-4c45-966f-
86ad86a68d63.jpg");
k = im2double(k);
w = ones(7, 7) / 49;
y_color = imfilter(k, w);
k_gray = rgb2gray(k);
y_gray = imfilter(k_gray, w);
subplot(2, 2, 1);
imshow(k);
title('Original Color Image', 'FontSize', 5);
subplot(2, 2, 2);
imshow(y_color);
title('Smoothed Color Image', 'FontSize', 5);
subplot(2, 2, 3);
imshow(k_gray);
title('Original Grayscale Image', 'FontSize', 5);
subplot(2, 2, 4);
imshow(y_gray);
title('Smoothed Grayscale Image', 'FontSize', 5);

Output-
EXP5.2

clc;
r = imread("C:\Users\naval\OneDrive\Desktop\f44b7b24-1549-4c45-966f-86ad86a68d63.jpg");
figure;
subplot(1, 2, 1);
imshow(r);
title('Original Color Image');
gray = rgb2gray(r);
a = double(gray);
[m, n] = size(a);
w = [1 1 1; 1 1 1; 1 1 1];
b = zeros(m, n);
for i = 2:m-1
for j = 2:n-1
b(i,j) = w(1)*a(i-1, j+1) + w(2)*a(i,j+1) + w(3)*a(i+1,j+1) ...
+ w(4)*a(i-1,j) + w(5)*a(i,j) + w(6)*a(i+1,j) ...
+ w(7)*a(i-1,j-1) + w(8)*a(i,j-1) + w(9)*a(i+1,j-1);
end
end
c = uint8(b);
subplot(1, 2, 2);
imshow(c);
title('Filtered Image');

Output-
EXP7

a = imread("C:\Users\naval\OneDrive\Desktop\wallpapersden.com_nezuko-demon-slayer-2024-ai-
art_1920x1080.jpg");
figure(1);
imshow(a);
title('Original Image');
b = imcrop(a, [40, 100, 1000, 500]);
figure(2);
imshow(b);
title('Cropped Image');
c = a(1:10:$, 1:10:$, :);
figure(3);
clf;
imshow(c);
title('Resized Image');
d = imrotate(a, 75);
figure(4);
imshow(d);
title('Rotated Image');
figure(5);
imshow(a(:, :, 1));
title('Segmentation of the image');
figure(6);
imshow(b(:, :, 3));
title('Segmentation of the Blue image');
figure(7);
imshow(a(:, :, 2));
title('Segmentation of the Green image');

Output-
EXP-6

clc;
i = imread("C:\Users\naval\OneDrive\Desktop\anime-night-sky-illustration.jpg");

figure();
subplot(2,2,1);
imshow(i);
title("Original Image");

se = ones(5, 5);

for k = 1:3
b(:,:,k) = imerode(i(:,:,k), se);
end
subplot(2,2,2);
imshow(b);
title("Eroded Image");
for k = 1:3
c(:,:,k) = imdilate(i(:,:,k), se);
end
subplot(2,2,3);
imshow(c);
title("Dilated Image");

be = ones(9, 9);
for k = 1:3
s2(:,:,k) = imopen(i(:,:,k), be);
end
subplot(2,2,4);
imshow(s2);
title("Opened Image");

ce = ones(11, 11);
for k = 1:3
s3(:,:,k) = imclose(i(:,:,k), ce);
end
figure();
imshow(s3);
title("Closed Image");

Output-
EXP-4

img = imread('/MATLAB Drive/Plumeria -8.jpg');


figure('Position', [100, 100, 1200, 800]);
subplot('Position', [0.08 0.55 0.4 0.4]);
imshow(img);
title('Original Image', 'FontSize', 8);
subplot('Position', [0.55 0.55 0.4 0.4]);
imhist(rgb2gray(img));
xlabel('Gray Level', 'FontSize', 6);
ylabel('Pixel Count', 'FontSize', 6);
yticks = 0:5e4:max(ylim);
yticklabels = arrayfun(@(x) num2str(x/1e4), yticks, 'UniformOutput', false);
set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
set(gca, 'XTick', 0:50:255);
set(gca, 'XTickLabel', arrayfun(@num2str, 0:50:255, 'UniformOutput', false));
title('Histogram of Original Image', 'FontSize', 8);
contrast_rgb = cat(3, histeq(img(:,:,1)), histeq(img(:,:,2)), histeq(img(:,:,3)));
subplot('Position', [0.08 0.05 0.4 0.4]);
imshow(contrast_rgb);
title('Contrast Image', 'FontSize', 8);
subplot('Position', [0.55 0.05 0.4 0.4]);
imhist(rgb2gray(contrast_rgb));
xlabel('Gray Level', 'FontSize', 6);
ylabel('Pixel Count', 'FontSize', 6);
yticks = 0:5e4:max(ylim);
yticklabels = arrayfun(@(x) num2str(x/1e4), yticks, 'UniformOutput', false);
set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
set(gca, 'XTick', 0:50:255);
set(gca, 'XTickLabel', arrayfun(@num2str, 0:50:255, 'UniformOutput', false));
title('Histogram of Contrast Image', 'FontSize', 8);
gray_img = rgb2gray(img);
figure('Position', [100, 100, 1200, 800]);
subplot('Position', [0.08 0.55 0.4 0.4]);
imshow(gray_img);
title('Original Grayscale Image', 'FontSize', 8);
subplot('Position', [0.55 0.55 0.4 0.4]);
imhist(gray_img);
xlabel('Gray Level', 'FontSize', 6);
ylabel('Pixel Count', 'FontSize', 6);
yticks = 0:5e4:max(ylim);
yticklabels = arrayfun(@(x) num2str(x/1e4), yticks, 'UniformOutput', false);
set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
set(gca, 'XTick', 0:50:255);
set(gca, 'XTickLabel', arrayfun(@num2str, 0:50:255, 'UniformOutput', false));
title('Histogram of Original Grayscale Image', 'FontSize', 8);
contrast_gray = histeq(gray_img);
subplot('Position', [0.08 0.05 0.4 0.4]);
imshow(contrast_gray);
title('Contrast Grayscale Image', 'FontSize', 8);
subplot('Position', [0.55 0.05 0.4 0.4]);
imhist(contrast_gray);
xlabel('Gray Level', 'FontSize', 6);
ylabel('Pixel Count', 'FontSize', 6);
yticks = 0:5e4:max(ylim);
yticklabels = arrayfun(@(x) num2str(x/1e4), yticks, 'UniformOutput', false);
set(gca, 'YTick', yticks, 'YTickLabel', yticklabels);
set(gca, 'XTick', 0:50:255);
set(gca, 'XTickLabel', arrayfun(@num2str, 0:50:255, 'UniformOutput', false));
title('Histogram of Contrast Grayscale Image', 'FontSize', 8);

Output-

You might also like