how to counting the number car in a image?
5 ビュー (過去 30 日間)
古いコメントを表示
I'm working about detecting and counting cars but am counting wrong. In image I have 1 car but am counting many cars.

My code:
A=imread('1image_72.jpg');
figure,imshow(A); title('Original Image');
%Convert the Image to binary
B=im2bw(A);
%Fill the holes
C=imfill(B,'holes');
%Label the connected components
[Label,Total]=bwlabel(C,8);
figure,imshow(C); title('Labelled Image');
%Rectangle containing the region
Sdata=regionprops(Label,'BoundingBox');
%Crop all the Cars
for i=1:Total
Img=imcrop(A,Sdata(i).BoundingBox);
Name=strcat('Object Number:',num2str(i));
figure,imshow(Img); title(Name);
end
0 件のコメント
採用された回答
Image Analyst
2015 年 5 月 10 日
You're simply doing a auto threshold, which most likely gives a terrible segmentation, and then basically counting all bright blobs regardless if they're a car, a reflection, a part of a car, or anything else. You can't do anything as simplistic as a global threshold. Maybe you should try stdfilt() and try to get areas that have a lot of variation in them, assuming that the road or parking lot will be smooth. Then threshold the stdfilt() image.
2 件のコメント
Image Analyst
2015 年 5 月 10 日
編集済み: Image Analyst
2015 年 5 月 10 日
It doesn't look like you used stdfilt() like I recommended. Anyway, that's a different image and could use a different algorithm. For that image you should detect red. See my File Exchange for color segmentation methods. http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
