![](/img/trans.png)
[英]Matlab: How to plot coordinate locations using x markers in a contour map?
[英]How to plot contour from points coordinate in matlab
我有一个图像和四个点(x1,y1),(x2,y2),(x3,y3),(x4,y4)。 它们是图像的像素坐标。 我想使用Matlab从图像周围的点生成一个轮廓。 我试图做到这一点,但它并不准确。 哪个实施更好?
X=[x1 x2 x3 x4];
Y=[y1 y2 y3 y4];
BW1 = roipoly(I,X,Y); % I is an image
figure,
imagesc(uint8(I),[0 255]),colormap(gray);axis equal;axis off;
hold on,[c1,h1] = contour(BW1,[0 0],'r','linewidth',1.4); hold off
也许这就是您想要做的(我在这里……):
X=[x1 x2 x3 x4];
Y=[y1 y2 y3 y4];
BW1 = roipoly(I,X,Y); % I is an image
figure
imagesc(uint8(I),[0 255])
colormap(gray);
axis equal;axis off;
hold on;
plot([X X(1)], [Y Y(1)], 'r', 'linewidth', 1.4); % <<<<< using plot instead of contour
也许你需要
[c1,h1] = contour(BW1,[0 0] + 0.5,'r','linewidth',1.4); hold off
第二种情况使用的事实是,根据需要,轮廓0.5将恰好位于0和1之间的边界上。 但是我怀疑您的BW1
图像会覆盖原始图像...很抱歉,目前无法测试,您还有很多猜测。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.