Connecting points on opposite end of mask

조회 수: 3 (최근 30일)
kunal
kunal 2025년 6월 19일
댓글: Image Analyst 2025년 6월 24일
Given an mask image i have certain points as seen in the image, I want to connect the point to the point at the opposite side of it given the list of points/array of point.Well the output would look something like.
  댓글 수: 9
kunal
kunal 2025년 6월 23일
The red points are the corner points where there is a drastic change in the angles and i am later using using connected point to divide this mask area in different 4 point segments that will be similar to rectangle.
Image Analyst
Image Analyst 2025년 6월 24일
I don't think this addressed any of the numbered questions. I don't see how that polygon would be divided into 4 rectangles. Anyway, if you go to the corners, the tips of the thick lines will be pointy arrowheads, not rectangles. But let's say you want to split that thick white line/polygon into 4 or more smaller rectangles. Why? And then what are you going to do with those rectangular masks?
I'm just trying to help but want to make sure you don't go on a wild goose chase for some solution you think will work but might not work.

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

채택된 답변

Matt J
Matt J 2025년 6월 20일
편집: Matt J 2025년 6월 23일
load('coping_data (1).mat')
img=logical(img);
n=height(points);
f=@(z,n) circshift(z,-n);
mod1=@(z) mod(z-1,n) + 1;
x=points(:,1)'; dx=diff([x,x(1)]);
y=points(:,2)'; dy=diff([y,y(1)]);
i=find(dy<-5 & f(dx,1)<-10 & f(dy,2)>+5 & abs(f(dx,1))<50 ,1);
I=mod1( i+2:i+n/2+1 );
J=flip( mod1( I(end)+(1:n/2) ) );
X=[x(I);x(J)]; Y=[y(I);y(J)];
imshow(img,[])
line(X,Y,'Color','r','LineWidth',3)

추가 답변 (1개)

Image Analyst
Image Analyst 2025년 6월 20일
If you can get the inner boundary and outer boundary as separate arrays, then it would be easy to find the boundary point closest to the red points by using pdist2. If you can't figure out pdist2 then I can do it if you give me the inside boundary and outside boundary.

Community Treasure Hunt

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

Start Hunting!

Translated by