How can i seperate the extruded are from portion from original boundary line ??
2 views (last 30 days)
Show older comments
I has two boundaries M and N which are extract from image. I measured the gap between the these two boundaries at each point, but there are some part is extruded in N boundary. I want to extract the that extruded portion from the N boundary. I tried this by given the angle and distance condition, but i could not able to do this.I attached the image and orange circle show the extruded portion. I also attached the code. Give some valuable suggestion for this. Thank You
0 Comments
Answers (1)
Yatharth
on 29 May 2024
Hi Surendra,
To measure the gap between the two boundaries, you can calculate the distance from each point on one boundary to the nearest point on the other boundary. This is computationally intensive but provides a detailed gap measurement.
Assuming the extruded portions of the boundary N are characterized by a larger gap to boundary M than the rest, you can identify these by finding where the gap exceeds a certain threshold.
Appending an updated version of the code you submitted:
M = readmatrix("M.xlsx"); N = readmatrix("N.xlsx");
xv = 506; yv = 115; pm = 16.167; ip = [xv, yv];
v = (81:1:710).';
figure(1)
set(gcf,'units','points','position',[400,150,700,510]);
plot(N(:,1), N(:,2),'g',M(:,1), M(:,2),'r');
set(gca,'XGrid','on','YGrid','on','YDir','reverse'); axis equal
hold on
plot([xv*ones(size(v)) M(v,1)].', [yv*ones(size(v)) M(v,2)].', '--r',xv, yv,'r+',[1 1]*xv, [0 yv], '-r');
hold off
% New code starts here
distances = zeros(size(N,1),1);
for i = 1:size(N,1)
dists = sqrt((M(:,1) - N(i,1)).^2 + (M(:,2) - N(i,2)).^2);
% Find the minimum distance for the current point
distances(i) = min(dists);
end
threshold = 10; % Define a threshold for the gap size that indicates an extrusion
extrudedIndices = find(distances > threshold);
% using the extrudedInces to get the points to plot
extrudedPoints = N(extrudedIndices, :);
figure();
plot(M(:,1), M(:,2), 'r-', N(:,1), N(:,2), 'b-', extrudedPoints(:,1), extrudedPoints(:,2), 'g*');
legend('Boundary M', 'Boundary N', 'Extruded Points');
xlabel('X-axis');
ylabel('Y-axis');
title('Identified Extruded Portions');
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!