I want to create a rectangular box like the green line.
1 次查看(过去 30 天)
显示 更早的评论
11/Empty%20Parking%20Lot.png>>
<</matlabcentral/answers/uploaded_files/137
I want the box to be created in that white cars place and it must autoatically detect that a car is present there. How can I do it ?????
0 个评论
回答(1 个)
Image Analyst
2014-6-4
What do you have to start with? Have you identified all the single spaces? If so, you can multiply the mask for one space by the current binary image. Then sum the pixels. If the number of pixels is greater than some minimum amount, like 10 pixels or so, then call it "Occupied" or "Taken". If the sum is less, then it's "Vacant" or "Available". Repeat for every single parking space mask.
Maybe you can then use fill() to place a red or green transparent shading/tinting over the parking place to indicate where it's taken or vacant.
3 个评论
Image Analyst
2014-6-4
You need to get a binary image of just the interior black quadrilaterals that define the parking spaces. Then you can label them and get into a loop where you extract one space using ismember(), then multiply it by the "test" image, and do the sum. Something like
[labeledImage, numberOfRegions] = bwlabel(refBinaryImage);
for k = 1 : numberOfRegions
thisRegion = ismember(labeledImage, k) > 0;
maskedImage = testBinary .* thisRegion;
sumPixels = sum(maskedImage(:));
if sumPixels > 10
% Occupied.
else
% Vacant
end
end
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!