I want to create a rectangular box like the green line.

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 ?????

Answers (1)

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

I'm using background subtraction frame difference. How I can pixel wise ???
I want a rectangle as that green line is in the Parking System side
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

Sign in to comment.

Categories

Asked:

on 4 Jun 2014

Commented:

on 4 Jun 2014

Community Treasure Hunt

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

Start Hunting!