How to select a particular region in a image, and segment it & compare it ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi all, I'm doing a project on Vacant parking space detection. I can able to detect the change in the entire frame but I want to detect for only particular space. can any one help? Thanks in advance.
video = VideoReader('demo_parking.mp4');
I = read(video,1);
Background = read(video,1);
Background1 =abs(Background - I);
for k = 1:500
if k== 1
Background = read(video,1);
else
% Change background slightly at each frame
% Background(t+1)=(1-alpha)*I+alpha*Background
Background1 =abs(Background - I);
end
I=k;
k=k+12;
grayImage = rgb2gray(Background1); % Convert to gray level
thresholdLevel = graythresh(grayImage); % Get threshold.
binaryImage = im2bw( grayImage, thresholdLevel); % Do the binarization
binaryImage = bwareaopen(binaryImage,1000);
se = strel('square', 5);
binaryImage=imdilate(binaryImage,se);
figure,imshow(binaryImage);
labeledImage = bwlabel(binaryImage, 8);
stats = regionprops(labeledImage,'BoundingBox','Area');
count=0;
total=8;
for j = 1 : length(stats)
thisBB = stats(j).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor','g','LineWidth',1 );
count=count+1;
end
disp(['No of parked vehicles are ',num2str(count)]);
disp(['No of available slots ',num2str(total-count)]);
end
0 commentaires
Réponses (1)
Image Analyst
le 7 Mai 2016
Use a template. Use roipoly() or roipolyold() to define the spaces on one of the frames. You can save the vertex coordinates in a .mat file if you want.
0 commentaires
Voir également
Catégories
En savoir plus sur Image Segmentation and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!