-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTraffic_monitoring_application.m
57 lines (54 loc) · 1.15 KB
/
Traffic_monitoring_application.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
clear all;
clc;
close all;
vid=VideoReader('video.mp4');
numFrames = vid.NumberOfFrames;
n=numFrames;
for i = 12n
frames = read(vid,i);
imwrite(frames,['Image' int2str(i), '.jpg']);
im(i)=image(frames);
end
location = 'xxx.jpg'; % folder in which your images exists
ds = imageDatastore(location) ;
im1=imread('Image1.jpg');
im1=rgb2gray(im1);
i=1;
while hasdata(ds)
img = read(ds) ; % read image from datastore
% creates a new window for each image
img=rgb2gray(img);
for k=1480
for j=1720
if im1(k,j)>=45
im1(k,j)=255;
else
im1(k,j)=0;
end
end
end
for k=1480
for j=1720
if img(k,j)>=45
img(k,j)=255;
else
img(k,j)=0;
end
end
end
imnew=xor(im1,img);
imnew=ordfilt2(imnew,1,ones(3));
imshow(imnew);
imwrite(imnew,[int2str(i), '.jpg']);
i=i+1;
end
% subplot(2,2,1);
% imshow(im1);
% subplot(2,2,2);
% imshow(img);
% subplot(2,2,3);
% imnew=xor(im1,img);
% imshow(imnew);
% subplot(2,2,4);
% fcbp=ordfilt2(imnew,1,ones(3));
% imshow(fcbp);