22ec620 Image Processing
22ec620 Image Processing
MODEL EXAMINATION
Section : ECE – B
REG.NO : 917722D063
QUESTION : To capture images of myself from K.S Auditorium and apply contrast
Enhancement .Detect edges before and after contrast enhancement.
Code:
clc;
clear all;
close all;
img = imread('naren2.jpg');
img = rgb2gray(img);
enhanced = histeq(img);
smoothed=double(enhanced);
sx = [-1 0 1; -2 0 2; -1 0 1];
im = padarray(smoothed, [1,1]);
res_x = zeros(size(img));
res_y = zeros(size(img));
for i = 2:size(im,1)-1
for j = 2:size(im,2)-1
c = im(i-1:i+1, j-1:j+1);
temp1 = c .* sx;
temp2 = c .* sy;
res_x(i-1,j-1) = sum(temp1(:));
res_y(i-1,j-1) = sum(temp2(:));
end
end
res_norm = mat2gray(res);
subplot(2,2,1);
imshow(img);
title('Original Grayscale');
subplot(2,2,2);
imshow(enhanced);
title('Histogram Equalized');
subplot(2,2,4);
imshow(res_norm);
smoothed=double(img);
sx = [-1 0 1; -2 0 2; -1 0 1];
im = padarray(smoothed, [1,1]);
res_x = zeros(size(img));
res_y = zeros(size(img));
for i = 2:size(im,1)-1
for j = 2:size(im,2)-1
c = im(i-1:i+1, j-1:j+1);
temp1 = c .* sx;
temp2 = c .* sy;
res_x(i-1,j-1) = sum(temp1(:));
res_y(i-1,j-1) = sum(temp2(:));
end
end
res_norm = mat2gray(res);
subplot(2,2,3);
imshow(res_norm);
output:
INPUT IMAGE 2 :
INPUT IMAGE 3