Hi, I have this shape in the plot, but I want to detect the 4 tails sticking out of the square in order to remove them. How could I detect them? I only have a single vector of points (x,y) which are in the plot. Attached is the variable containing the points.
Thanks!

댓글 수: 4

Image Analyst
Image Analyst 2022년 4월 8일
So it's not a digital image, but a plot? That means you plotted it somehow. So just don't plot the lines. Only plot the square. You're the one who plotted it so you have complete control over what gets plotted. Or is there something I'm missing?
It's a plot, i just did:
% size(data) = [1000,2];
plot(data(:,1),data(:,2),'.');
Since there are a lot of points it seems there are lines but no, the supposed 'line' is a series of points that get out of the principal square. My question is that I would like to find a condition for these points so that I could remove them as:
% cond is the condition
data(cond,:)=[];
Les Beckham
Les Beckham 2022년 4월 8일
If you attach your data as a mat file using the paperclip (either edit your question or add it in a comment), it will make it easier to help you.
Albert
Albert 2022년 4월 8일
I have attached the mat file!

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

 채택된 답변

Matt J
Matt J 2022년 4월 8일
편집: Matt J 2022년 4월 8일

1 개 추천

load data_points
data0=data;
shp=alphaShape(data,0.9);
[~,V]=boundaryFacets(shp);
shp=polyshape(V,'Simplify',true);
Warning: Polyshape has duplicate vertices, intersections, or other inconsistencies that may produce inaccurate or unexpected results. Input data has been modified to create a well-defined polyshape.
for i=[-1,sqrt(2)]
shp=polybuffer(shp,i,'Joint','square');
end
tf=shp.isinterior(data);
data=data(tf,:);
plot(data0(:,1),data0(:,2),'o',data(:,1),data(:,2),'.r'); hold on

댓글 수: 3

Albert
Albert 2022년 4월 8일
cool! but in the end I want another vector of points data2. Should I use inpolygon with the vertices computed and filter the data?
Matt J
Matt J 2022년 4월 8일
Yes, or you could use isinterior() as in my now modified solution.
Albert
Albert 2022년 4월 11일
thanks!

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

추가 답변 (0개)

카테고리

제품

질문:

2022년 4월 8일

댓글:

2022년 4월 11일

Community Treasure Hunt

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

Start Hunting!

Translated by