how can we detect vehicles using matlab

1 Ansicht (letzte 30 Tage)
seelam shanmukha kalyan
seelam shanmukha kalyan am 24 Apr. 2020
Bearbeitet: KSSV am 24 Apr. 2020
respected sir/mam
i am unable to detect exact number of vehicles in the presence of day light and during the nights.here is my code with which i am working with to tackle this problem.can you please guide me to solve this problem.
clc;
close all;
clear all;
f=imread('C:\Users\Pratyusha\Desktop\project pics\morning 1030\2.jpg');
f=imresize(f,[800 NaN]);
figure (1)
imshow(f)
g=rgb2gray(f);
g=im2bw(g);
g=medfilt2(g,[5 5]);
figure (2)
imshow (g)
conc=strel('disk',5);
gi=imdilate(g,conc);
figure(3);
imshow(gi);
conc1=strel('disk',5);
ge=imerode(gi,conc1);
figure(4);
imshow(ge);
gdiff=imsubtract(gi,ge);
figure(5);
imshow(gdiff);
gdiff1=mat2gray(gdiff);
figure (6)
imshow (gdiff1)
gdiff2=conv2(gdiff1,[1 1;1 1]);
figure (7)
imshow (gdiff2)
gdiff3=imadjust(gdiff2,[0.5 0.7],[0 1],0.1);
figure (8)
imshow (gdiff3)
B=logical(gdiff3);
[a1 b1]=size(B);
figure(9)
imshow(B)
er=imerode(B,strel('line',60,8));
figure(10)
imshow(er)
out1=imsubtract(B,er);
F=imfill(out1,'holes');
H=bwmorph(F,'thin',1);
H=imerode(H,strel('line',8,55));
figure(11)
imshow(H)
I=bwareaopen(H,floor((a1/18)*(b1/18)));
I(1:floor(.9*a1),1:2)=1;
I(a1:-1:(a1-20),b1:1:(b1-2))=1;
figure(12)
imshow(I)
figure (13)
imshowpair (f,I)
Iprops=regionprops(I,'BoundingBox','Image');
hold on
text(8,785,strcat('\color{green}Cars Detected:',num2str(length(Iprops))))
hold on
for n=2:size(Iprops,1)
rectangle('Position',Iprops(n).BoundingBox,'EdgeColor','g','LineWidth',2);
end
hold off

Antworten (0)

Kategorien

Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by