how to label the vacant space

1 次查看(过去 30 天)
this is my coding that i have created..
I=imread('park2.jpg');
imshow(I);
gray=rgb2gray(I);
imshow(gray);
Binary = I;
BW = im2bw(Binary, graythresh(Binary));
BW = ~BW;
figure, imshow(BW)
L = bwlabel(BW);
s = regionprops(L, 'Centroid');
imshow(BW)
hold on
for k = 1:numel(s)
c = s(k).Centroid;
text(c(1), c(2), sprintf('%d', k), ...
'HorizontalAlignment', 'center', ...
'VerticalAlignment', 'middle');
end
hold off
however,the label is not right.. i want to label the vacant space only and want to display the output of vacant space.. this is how it goes http://s17.postimage.org/wimc8cbzz/parking.jpg
please help me solve this

采纳的回答

Geoff
Geoff 2012-5-25
I wouldn't use regionprops here. That just connects pixels. You can't guarantee that will have anything to do with empty parking spaces in a thresholded image.
The first thing I would do is work out where the car parks are. I would do this manually if it's a fixed camera, but if I had to detect it I might try a hough transform looking for evenly-spaced groups of parallel lines. The point is that I would expect a certain structure - I wouldn't just go in blind, expecting the most basic of image processing techniques to work. Because in my opinion there is no real-world application for a totally automatic and calibration-free parking vacancy system.
Once I had a bounding rectangle for each park, I'd then look at all the pixels in each parking rectangle (or quad, if I expected any nontrivial camera rotation) and make the call on whether I think there's a car in that rectangle or not. To do that I would have heuristics relating to the size and shape (and colour) of pixel blobs, as well as their density and distribution within the rectangle. For example, if a person or shopping trolley was sitting in a vacant space, I might not want to detect it as a car.
  4 个评论
Syazwan
Syazwan 2012-5-25
could you guys give me a sample coding or example because i am new in this matlab world..
if there is an example,i can make it as my reference..
by the way,thank a lot for gave me some advice...
Walter Roberson
Walter Roberson 2012-5-25
http://www.mathworks.com/matlabcentral/answers/8026-best-way-s-to-master-matlab

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Image Segmentation and Analysis 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by