【问题标题】:Distance image to objects in matlab距离图像到matlab中的对象
【发布时间】:2012-12-06 03:13:18
【问题描述】:

我有一个包含一些点(或对象)的图像。我想基于此图像创建另一个图像,以显示与这些对象的距离。例如,这个新图像应该在对象位置处具有最大值。 matlab有解决办法吗?

【问题讨论】:

  • 您要显示的距离是多少? “...与这些物体的距离”并不能清楚地说明您测量的是相对于什么。

标签: image matlab object image-processing


【解决方案1】:

您可以为此使用bwdist,它会计算二进制图像中每个像素与信号的距离。

%# read the image
img = imread('http://i.stack.imgur.com/Hc7ay.png');
%# convert to grayscale
gs = im2bw(img);
%# segment the objects
sig = gs~=1;
%# remove the border
sig = sig(5:end-4,5:end-4);

%# calculate the distance
distFromObjects = -bwdist(sig);

【讨论】:

  • 看起来像一个 voronoi digram,不是吗?
  • 是的,因为 voronoi 图就是这样定义的 :)
  • 非常感谢 Jonas,但我如何控制半径? matlab和bwdist中没有这个选项。
  • @Sam:当你想只显示一个特定的距离,比如10个像素,你可以imshow(distFromObjects==10)
  • @Jonas,我在 SO 中发布了一个有趣的问题。也许你也有兴趣 :-) stackoverflow.com/questions/22116123/…
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-08-27
  • 2013-09-02
  • 1970-01-01
  • 1970-01-01
  • 2022-01-20
  • 1970-01-01
  • 2014-10-16
相关资源
最近更新 更多