image - 距离图像到matlab中的物体

标签 image matlab object image-processing

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

enter image description here

最佳答案

您可以为此使用 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);

enter image description here

关于image - 距离图像到matlab中的物体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13729839/

相关文章:

html - 如何在 img 标签上创建渐变

algorithm - 二进制搜索与一次固定一个数字

Ruby:案例使用对象

matlab - 如何确定Matlab中子图的尺寸?

matlab - Matlab中具有不同维度的多个数据集的直方图

javascript - 具有嵌套对象数组的对象数组

javascript - 从对象 : object. 中调用函数 function()

image - 如何使用 Ghostscript 从 pdf 文件获取 24 位深度的 LZW tiff

jquery - jQuery选择选项图像

php - 显示动态创建路径中的图像