-
Notifications
You must be signed in to change notification settings - Fork 1
/
Mymainhsv.m
44 lines (43 loc) · 1.37 KB
/
Mymainhsv.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
clc;clear;
% channels-adding noise-median smooth-unsharp mask-proposed filter-morphology
I=imread('baboon.png');
% [finr fing finb K]=Finalreshsv(I);
% subplot(1,4,1), subimage(h);title('H');
% subplot(1,4,2), subimage(s);title('S');
% subplot(1,4,3), subimage(v);title('V');
% subplot(1,4,4), subimage(I);title('HSV');
%
mean=0;
variance=0.01;
noisedensity=0.1;
specklevariance=0.01;
figure;
gaussiannoise = imnoise(I,'gaussian',mean,variance);
[finr fing finb K]=Finalreshsv(gaussiannoise); Kgauss=K;
figure;
saltynoise = imnoise(I,'salt & pepper',noisedensity);
[finr fing finb K]=Finalreshsv(saltynoise);Ksalt=K;
figure;
poissonnoise = imnoise(I,'poisson');
[finr fing finb K]=Finalreshsv(poissonnoise);Kpoisson=K;
figure;
specklenoise = imnoise(I,'speckle',specklevariance);
[finr fing finb K]=Finalreshsv(specklenoise);Kspeckle=K;
%% morphology
%imerode
se = strel('disk',1);
Kgaussmorph = imerode(Kgauss,se);
Ksaltmorph = imerode(Ksalt,se);
Kpoissonmorph = imerode(Kpoisson,se);
Kspecklemorph = imerode(Kspeckle,se);
%imclose
se = strel('disk',1);
Kgaussclose = imclose(Kgaussmorph,se);
Ksaltclose = imclose(Ksaltmorph,se);
Kpoissonclose = imclose(Kpoissonmorph,se);
Kspeckleclose = imclose(Kspecklemorph,se);
%% hit miss function
output1=hitmiss(Kgaussclose);
output2=hitmiss(Ksaltclose);
output3=hitmiss(Kpoissonclose);
output4=hitmiss(Kspeckleclose);