-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMorfologicOperationsOnGrayScale.m
112 lines (80 loc) · 1.42 KB
/
MorfologicOperationsOnGrayScale.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
close all;
clc;
clear;
img=imread('ferrari.bmp');
str=strel('square',3);
img_erode=imerode(img,str);
figure(1);
subplot(1,3,1);
imshow(img);
title('Orginal');
subplot(1,3,2);
imshow(img_erode);
title('Eroded');
img_dif=imabsdiff(img,img_erode);
subplot(1,3,3);
imshow(img_dif);
title('Diffrance');
figure(2);
img_dylate=imdilate(img,str);
subplot(1,3,1);
imshow(img);
title('Orginal');
subplot(1,3,2);
imshow(img_dylate);
title('Dylateted');
img_dif_2=imabsdiff(img,img_dylate);
subplot(1,3,3);
imshow(img_dif_2);
title('Diffrance');
figure(3);
subplot(1,2,1);
imshow(img_dif);
title('Erosion Diff');
subplot(1,2,2);
imshow(img_dif_2);
title('Dilatation Diff');
%%
%Open Close
img=imread('ferrari.bmp');
str=strel('square',3);
img_open=imopen(img,str);
img_close=imclose(img,str);
figure(4);
subplot(1,3,1);
imshow(img);
title('Orginal');
subplot(1,3,2);
imshow(img_open);
title('Open');
subplot(1,3,3);
imshow(img_close);
title('Close');
%%
%Top Bottom Hat
img=imread('ferrari.bmp');
str=strel('square',3);
img_top=imtophat(img,str);
img_bot=imbothat(img,str);
figure(5);
subplot(1,3,1);
imshow(img);
title('Orginal');
subplot(1,3,2);
imshow(img_top);
title('TopHat');
subplot(1,3,3);
imshow(img_bot);
title('BotHat');
%%
%Using TopHAt
img=imread('rice.png');
str=strel('disk',10);
img_top=imtophat(img,str);
figure(6);
subplot(1,2,1);
imshow(img);
title('Orginal');
subplot(1,2,2);
imshow(img_top);
title('TopHat');