I want to create a rectangular box like the green line.
3 views (last 30 days)
Show older comments

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 Comments
Answers (1)
Image Analyst
on 4 Jun 2014
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 Comments
Image Analyst
on 4 Jun 2014
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
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!