【发布时间】:2020-12-13 21:28:29
【问题描述】:
我找不到在表面的上下脊上绘制一些点的方法。 我为表面编写了这段代码:
%initialize parameters
x = linspace(-2,2,100);
y = linspace(-2,2,80);
fxy = abs(log(x'.*y));
% it looks like this
figure(1), clf
surf(x,y,fxy')
shading interp
axis square, rotate3d on
xlabel('X'), ylabel('y'), zlabel('f(x,y)')
为了找到较低的山脊,我写了如下内容:
% find min
minval = min(min(fxy));
[xi,yi] = find( minval == fxy);
idx = sub2ind(size(fxy),xi,yi);
% plot the minimum as a red ball
hold on
plot3(x(xi),y(yi),fxy(idx)','ro', 'MarkerFaceColor','r','MarkerSize',12 )
然后对于下限(下脊),我将阈值设置为 0.1,然后:
% finding lower ridge : points below a threshold of .01
[xi,yi] = find( fxy < minval+.01);
% to get the values, convert from matrix indices to linear indices
idx = sub2ind(size(fxy),xi,yi);
% plot the close-to minimum points
plot3(x(xi),y(yi),fxy(idx)','ro','markerfacecolor','r','markersize',12)
现在我做到了最大程度:
% finding maximum
maxval = max(max(fxy));
[xi,yi] = find( maxval == fxy);
% plot the maximum as a red ball
plot3(x(xi),y(yi),fxy(xi,yi)','ro', 'MarkerFaceColor','r','MarkerSize',12 )
现在我怎样才能找到上山脊?我将阈值设置为上限 5,结果是这样的:
% finding upper ridge : points below a threshold of 5
[xi,yi] = find( maxval- fxy <5);
% to get the values, convert from matrix indices to linear indices
idx = sub2ind(size(fxy),xi,yi);
% plot the close-to minimum points
plot3(x(xi),y(yi),fxy(idx)','ro','markerfacecolor','r','markersize',12)
哪个是仅获得上山脊的最佳阈值?有没有其他方法只在上边缘绘制点?
【问题讨论】:
-
你想获得什么作为“上边缘”?您需要考虑的是,对
f(x,y)使用粗略的水平阈值将导致水平表面上方的所有点(图像中大约为z=3.2)都被标记。如果您想要真正的边缘,这比应用简单的一维阈值要复杂得多。您需要使用我认为的导数以某种方式识别这些边缘。 -
我不知道你想做什么,但从数学上讲,因为
abs(log(0)) = inf没有“上山脊”这样的东西。因此,突出显示数字伪影很奇怪。