我有一张包含一些点(或对象)的图像。我想基于此图像创建另一个图像,以显示与这些对象的距离。例如,这个新图像应该在对象位置具有最大值。有matlab中的解决方法吗?
最佳答案
您可以为此使用 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);
关于image - 距离图像到matlab中的物体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729839/