Geometric shape detection with regionprops

조회 수: 5 (최근 30일)
Simon Dussault
Simon Dussault 2013년 2월 8일
댓글: Ahaana Khurana 2020년 2월 4일
Hi i want to modified hte code i have to be abble to detect horizontal rectangle and vertical rectangle. Right now, the code i have can detect square circle and triangle real well. So how should i modify the extent and eccentricity for detecting rectangles?
Here's the code :
function [Boxes] = ObjDt(InputImg) %Rajouté BoxesPos
% function determining whether the unknown objects by their geometric shape
% count the number of found objects
Index=1;
% structure to store the coordinates of the outlines of the detected objects
Boxes=struct('Box',[]);
% BoxesCell=struct2cell(Boxes); %Rajouté pour avoir les Coordonnées dans un vecteur
% BoxesPos=cell2mat(BoxesCell); %Rajouté pour avoir les Coordonnées dans un vecteur
for s=1:3
%color filtration
img = double(ColorDt(InputImg,s));
% determine the number of objects in the image
[imgN, num] = bwlabel(img,4);
% obtain the properties of detected objects
f = regionprops(imgN,'BoundingBox','Centroid','Extent','Eccentricity'); %Changer imfeature pour regionprops
%square
for i=1:num
if(f(i).Extent>=0.78) & (f(i).Extent<0.95) & (f(i).Eccentricity<0.9) & (f(i).Eccentricity>=0.2)
Boxes(Index).Box=f(i).BoundingBox;
Index=Index+1;
end
end
%circle
for i=1:num
if(f(i).Extent<0.78) & (f(i).Extent>=0.65) & (f(i).Eccentricity<0.8) & (f(i).Eccentricity>0.3)
Boxes(Index).Box=f(i).BoundingBox;
Index=Index+1;
end
end
%triangle
for i=1:num
if(f(i).Extent>0.3) & (f(i).Extent<0.6) & (f(i).Eccentricity<0.8) & (f(i).Eccentricity>0.2)
Boxes(Index).Box=f(i).BoundingBox;
Index=Index+1;
end
end
end
end
  댓글 수: 2
Susenjit Ghosh
Susenjit Ghosh 2017년 12월 29일
what to enter in input image while running
Ahaana Khurana
Ahaana Khurana 2020년 2월 4일
The code is not working. Pls check the code and revert

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2013년 2월 8일
No, you don't look at the eccentricity. You can look either at the orientation, or check the width vs. height of the bounding box.

추가 답변 (1개)

Paul
Paul 2014년 2월 22일
Hello,
I am very interested in what you are doing. I have been doing research for undergraduate and would like to know more about your program. Would this program find how many circle objects are in an RGB image? Email : pfon1800@students.vsu.edu Cell : 3017934167

카테고리

Help CenterFile Exchange에서 Coordinate Systems에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by