以下是處理這個問題的一個建議:
- 定義的Z高度的閾值,或其中從散射點的任何其他方式定義是相關的(在下面的最左邊的圖中的黑色平面) 。
- 在結果點內,在X-Y平面上查找聚類,以定義要計算的不同區域。你將不得不手動定義你想要的羣集數量。
- 對於每個羣集,執行Delaunay三角測量以估計其體積。
這裏是所有的示例代碼:
[x,y,z] = peaks(30); % some data
subplot 131
scatter3(x(:),y(:),z(:),[],z(:),'filled')
title('The original data')
th = 2.5; % set a threshold for z values
hold on
surf([-3 -3 3 3],[-4 4 -4 4],ones(4)*th,'FaceColor','k',...
'FaceAlpha',0.5)
hold off
ind = z>th; % get an index of all values of interest
X = x(ind);
Y = y(ind);
Z = z(ind);
clustNum = 3; % the number of clusters should be define manually
T = clusterdata([X Y],clustNum);
subplot 132
gscatter(X,Y,T)
title('A look from above')
subplot 133
hold on
c = ['rgb'];
for k = 1:max(T)
valid = T==k;
% claculate a triangulation of the data:
DT = delaunayTriangulation([X(valid) Y(valid) Z(valid)]);
[K,v] = convexHull(DT); % get the convex hull indices
% plot the volume:
ts = trisurf(K,DT.Points(:,1),DT.Points(:,2),DT.Points(:,3),...
'FaceColor',c(k));
text(mean(X(valid)),mean(Y(valid)),max(Z(valid))*1.3,...
num2str(v),'FontSize',12)
end
hold off
view([-45 40])
title('The volumes')
注:這個代碼從幾個工具箱使用不同的功能。在任何情況下,一些不起作用的,首先確保你有相關的工具箱,有大部分的替代品。
來源
2017-08-01 01:14:09
EBH
是什麼讓這些山峯變得特別。我們沒有您的數據,通過查看圖片並不容易掌握您的想法和數據集中發生的事情。 – Masoud
峯值表示高像素值,我的問題的一部分是想知道如何建立一個自動化的「基準」/閾值,高於該閾值數據被視爲「峯值」。我的數據是每個像素一個圖像的一個點,所以它非常分散,所以我難以確定如何建立一個良好的基面來建立峯值。 – Anonymous
這些數據是描述整個圖像,還是隻是它的一部分? – KjMag