作者drummerworld (Donkin??Donkey)
看板MATLAB
标题[讨论] bwdistgeodesic 函式
时间Fri Oct 11 14:21:08 2013
各位板上大大们好
小弟想把骨架图上每个endpoint到branchpoint的边砍掉
因此利用 bwdistgeodesic 这个function
计算skel里从endpoint 走到 branch point的路径。
并根据原本的骨架图删除上述的路径
我的方法如下:
1.从每个endpoint出发,并找到离各个endpoint最近的branch point
2.纪录该endpoint到最近branchpoint的路径
3.原本骨架图和上述纪录的路径相减得知
程式如下:
%找出ima的骨架
skel= bwmorph(ima,'skel',Inf);
%针对骨架找出branchpoints
B = bwmorph(skel, 'branchpoints');
%针对骨架找出endpoints
E = bwmorph(skel, 'endpoints');
%找出endpoints的座标及branchpoints在矩阵的非 0 element
[y,x] = find(E);
B_loc = find(B);
%建立同skel相同size的0矩阵,用来标记各个endpoint到最近branch的路径
Dmask = false(size(skel));
%针对endpoint的x长度跑回圈
for k = 1:length(x)
%从骨架图的每个endpoint出发,并找寻附近最近的branchpoint,延途把此endpoint
到最近branchpoint的路径标记到mask中
D = bwdistgeodesic(skel,x(k),y(k));
distanceToBranchPt = min(D(B_loc));
Dmask(D < distanceToBranchPt) =true;
end
%得到新骨架图,该图为以去除branch到endpoint的边
skelD = skel - Dmask;
%秀图
imshow(skelD);
hold all;
[y,x] = find(B); plot(x,y,'ro')
但是执行到bwdistgeodesic这function时
显示??? Undefined function or method 'bwdistgeodesic' for
input arguments of type 'double'
去看了一下x(k)和y(k)都是整数 (x,y是endpoint的座标)
只是怎麽会产生这麽问题呢?
跪求板上大大们的指引
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 120.127.47.203