-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprob4.m
64 lines (49 loc) · 1.04 KB
/
prob4.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
clear;
%Inporting Image
IMGG = imread('1.jpg');
IMG = IMGG(:,:,1);
%Backup original image
%Laplacian Filter Masks
W = [0 1 0;1 -4 1; 0 1 0];
%W = [1 1 1;1 -8 1; 1 1 1];
%Padding the boundary with zeros
IMG = padarray(IMG,[1,1]);
IMG1 = IMG;
I = zeros(size(IMG));
IMG = double(IMG);
%Computing the Laplasian mask
for i = 2:size(IMG,1)-1
for j = 2:size(IMG,2)-1
I(i,j) = sum(sum(W .* IMG(i-1:i+1,j-1:j+1)));
end
end
I = uint8(I);
%Sharpenend Image
B = IMG1 - I;
%Gradient Filter Masks
W = [-1 -2 -1; 0 0 0; 1 2 1];
I = zeros(size(IMG));
IMG = double(IMG);
%Computing the Laplasian mask
for i = 2:size(IMG,1)-1
for j = 2:size(IMG,2)-1
I(i,j) = sum(sum(W .* IMG(i-1:i+1,j-1:j+1)));
end
end
I = uint8(I);
%Sharpenend Image
B1 = IMG1 - I;
%Displaying the result
figure,
subplot(2,2,1),
imshow(IMG1);
title('Original Image');
subplot(2,2,2),
imshow(I);
title('Laplacian Mask');
subplot(2,2,3),
imshow(B);
title('Laplacian Sharped Image');
subplot(2,2,4),
imshow(B1);
title('Gradient Sharped Image');