-
Notifications
You must be signed in to change notification settings - Fork 1
/
kati.m
126 lines (103 loc) · 2.53 KB
/
kati.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
%% arxika
clear all;
close all;
clc;
load('dip_hw_3.mat');
rng(1);
%fila=exoyn 1 h kanena paidi
%% d2a me T1
disp('Calculating 1o peirama...');
img=d2a;
tic;
W=Image2Graph(img);
%imshow(W1,[]);
time1=toc;
%% anadromiki me8odos
%tic
k=2;
global count;
count=0;
global p;
p=struct;
T1=1300;%1500 gia 1 bima mono
T2=0.20;
global sth;
sth=1;
level=0;
global c;
c=0;
global filo;
%% apo edw ksekiname
%1h fora. prepei na einai ektos anadromis giati xreiazomai ta proigoymena
%WA kai WB ta opoia den iparxoyn stin arxi.
tic
count=count+1;%count=1;
p(count).W=W;
clusterIdx=myNcuts(p(count).W,k);
p(count).nCutValue=calculateNcut(p(count).W,clusterIdx);
perioxesA=find(clusterIdx==1);
perioxesB=find(clusterIdx==2);
p(count).imOutA=print(perioxesA,img);
WA= Image2Graph(p(count).imOutA);
p(count).imOutB=print(perioxesB,img);
WB= Image2Graph(p(count).imOutB);
%des an 8a sinexisei i dixotomisi apo to 1o kommati
if (length(perioxesA)>T1)
p(count).WA=WA;
else
p(count).WA=[];
end
%des an 8a sinexisei i dixotomisi apo to 2o kommati
if (length(perioxesB)>T1)
p(count).WB=WB;
else
p(count).WB=[];
end
% if p(count).WA==0
% if p(count).WB==0
% c=c+1;
% filo(c)=count;
% end
% end
%bazoyme ston pinaka filo, tis eikones pou 8a xwristoun ,estw mono apo tin mia
%meria
%an einai adio to WA tote elenxoyme an einai adio kai to WB gia na
%ektiposoyme tis antistixes eikones
if (isempty(p(count).WA))
if (~isempty(p(count).WB))
imshow(p(count).imOutA);
end
imshow(p(count).imOutA);
imshow(p(count).imOutB);
else
if (isempty(p(count).WB))
imshow(p(count).imOutB);
end
end
time2=toc;
%%
tic;
global teloscounter;
teloscounter=0;
while 1
for i=1:2^level
myRecNcutsA(k,T1,p((count+1)-sth).imOutA);%k=2,p(1),count=1;
myRecNcutsB(k,T1,p((count)-sth).imOutB);%k=2,p(1),count=1;
end
level=level+1;
if teloscounter==2^(level) %an exw midenika osa einai to level simainei oti exw mono fila kai sinepws prepei na teliwsei i anadromi
break;
else
teloscounter=0;
end
end
timerec=toc;
%printare oles tis eikones poy prokiptoyn apo fila
tic;
for i=1:length(filo) % pame me bima 2 dioti sto pinaka filo
figure;
imshow(p(filo(i)).imOutA);
figure;
imshow(p(filo(i)).imOutB);
end
timeend=toc;