2
我在硬币图像中用绿色标记了一个硬币(绿色),并在其上通过一条线。我如何找到它们相交的x,y点? 在此先感谢。线和对象的交点 - Matlab
clc;
clear;
I = imread('coins.png');
BW = im2bw(I);
BW_filled = imfill(BW,'holes');
boundaries = bwboundaries(BW_filled);
figure,imshow(I) ;
hold on;
b = boundaries{1};
plot(b(:,2),b(:,1),'g','LineWidth',1);
h = imline;
myPoints = wait(h);
delete(h) ;
x1 = round(myPoints(1,1),2);
y1 = round(myPoints(1,2),2);
x2 = round(myPoints(2,1),2);
y2 = round(myPoints(2,2),2);
%plot line
x=[x1 x2];
y=[y1 y2];
plot(x',y','r')
有没有一种方法,使之更加敏感?例如通过添加所有这些点之间的距离 – hsi
@ user2676173是的,您可以添加检查前四个点之间的相对距离。寻找第一对两个分开的可辨距离。 – Yvon
是否有可能用点替换散点图? – user2916044