gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-03 20:19:16 26 4
gpt4 key购买 nike

我有一张包含一些点(或对象)的图像。我想基于此图像创建另一个图像,以显示与这些对象的距离。例如,这个新图像应该在对象位置具有最大值。有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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com