-
Notifications
You must be signed in to change notification settings - Fork 0
/
Mask_Proc.m
48 lines (48 loc) · 1.29 KB
/
Mask_Proc.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
%% Taking input from user for choice of image
prompt='Please enter choice of image:\n';
k=input(prompt,'s');
i=imread(k);
%% Obtain a section of the image
dimsn=size(i);
isec=i(0.25*dimsn(1):0.75*dimsn(1),0.25*dimsn(2):0.75*dimsn(2),1:3);
%% Display image as well as image section
figure(1)
subplot(121);
imshow(i);
subplot(122);
imshow(isec);
%% Input from user for number of neighbouring pixels to be considered
prompt='Enter number of pixels to be considered for averaging (in terms of dimension of square):\n';
k1=input(prompt);
%% Calling averaging filter
iavg=avgfilter(isec,k1,3);
%% Putting it back into original image
imod=i;
imod(0.25*dimsn(1):0.75*dimsn(1),0.25*dimsn(2):0.75*dimsn(2),1:3)=iavg;
%% Display original and generated image
figure(2)
subplot(1,2,1);
imshow(imod);
subplot(1,2,2);
imshow(i);
%% Calling sharpening filter
prompt='Enter number of pixels to be considered for sharpening (in terms of dimension of square):\n';
k1=input(prompt);
isharp=genshpfilter(i,k1,3);
%Negative of Sharpened image
ineg=255-isharp;
%% Display original and generated image
figure(3)
subplot(1,3,1);
imshow(isharp);
subplot(1,3,2);
imshow(i);
subplot(1,3,3);
imshow(ineg);
%% Unsharp Masking
igray=rgb2gray(i);
iblur=avgfilter(igray,k1,1);
irmblur=igray-iblur;
%% Display generated image
figure(4)
imshow(irmblur);