【发布时间】:2012-12-06 03:13:18
【问题描述】:
我有一个包含一些点(或对象)的图像。我想基于此图像创建另一个图像,以显示与这些对象的距离。例如,这个新图像应该在对象位置处具有最大值。 matlab有解决办法吗?
【问题讨论】:
-
您要显示的距离是多少? “...与这些物体的距离”并不能清楚地说明您测量的是相对于什么。
标签: image matlab object image-processing
我有一个包含一些点(或对象)的图像。我想基于此图像创建另一个图像,以显示与这些对象的距离。例如,这个新图像应该在对象位置处具有最大值。 matlab有解决办法吗?
【问题讨论】:
标签: image matlab object image-processing
您可以为此使用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);
【讨论】:
imshow(distFromObjects==10)