-
Notifications
You must be signed in to change notification settings - Fork 1
/
video.asv
71 lines (63 loc) · 1.56 KB
/
video.asv
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
B = '.png';
C = 'yjf-00_1-';
k=1;
for k=1:50
d=num2str(k);
e2=strcat(C,d);
filename3 =strcat(e2,B);
a=imread('yjf-00_1-bk.png');
b=imread( filename3);
a1=a(:,:,1);
a2=a(:,:,2);
a3=a(:,:,3);
%[r c]=size(a1);
b1=b(:,:,1);
b2=b(:,:,2);
b3=b(:,:,3);
z1= imsubtract(a1,b1);
z2= imsubtract(a2,b2);
z3= imsubtract(a3,b3);
fig(:,:,1)=z1;
fig(:,:,2)=z2;
fig(:,:,3)=z3;
I2=rgb2gray(fig);
I3 = imadjust(I2, stretchlim(I2), [0 1]);
level = graythresh(I3);
bw = im2bw(I3,level);
K = medfilt2(bw);
K6 = medfilt2(K,[5,5]);
% k6=double(K6);
% K6=edge(K6,'canny');
% imshow(K6,[])
k=k+1;
Image = K6;
% get size of image as H,W
imshow(b);
[H,W] = size(Image);
[r,c] = find( bwperim(Image,4) == 1 );
[tr,tc] = boundarytrack(r,c,H,W,0);
% X1=tr;
% Y1 =tc;
XB=tr;
YB =tc;
Xmin = min(XB);
Ymin = min(YB);
Xmax = max(XB);
Ymax = max(YB);
X = [Xmin,Xmax];
Y = [Ymin,Ymin];
line(Y,X) ;
X = [Xmin,Xmin];
Y = [Ymin,Ymax];
line(Y,X) ;
X = [Xmax,Xmax];
Y = [Ymin,Ymax];
line(Y,X) ;
X = [Xmin,Xmax];
Y = [Ymax,Ymax];
line(Y,X) ;
%Yg = Xmin+fix((Ymax-Ymin)/2);
%Xg = Ymin+fix((Xmax-Xmin)/2);
%line(Yg,Xg);
pause(0.5);
end