1

我有一个矩阵。

Mat_=[ x y z intensity];

e.g., intensity= rand(100,1)

现在我想根据强度对我的观点进行着色和分类。说我想要 6 或 10 节课。我也想用彩条展示它。最好的方法是什么。

4

2 回答 2

2

您可以使用kmeans集群intensity成所需数量的集群。然后根据聚类强度得到的指标进行聚类(假设和[x y z]之间存在一一对应关系)。然后可能为每个集群分配不同的颜色,然后显示。[x y z]intensity

于 2013-04-16T03:16:04.483 回答
2

您可能想要这样:请注意,我不会将数据聚集成碎片,我只是将它们绘制在颜色栏中,并使用它们所具有的强度值。你可能想改变它,但我认为这并不难;)(提示:mod可能会有所帮助)。

PD:kmeans也可以

% Create data
[X,Y] = meshgrid(-2:.2:2, -2:.2:2);                                
Z = X .* exp(-X.^2 - Y.^2);

intensity= rand(size(X));

%Get max and min
m=min(min(intensity));
M=max(max(intensity));

%set colorbar property
caxis([m M]); 
colorbar();

%get colors by intensity
colors=zeros(size(X,1),size(X,2),3);
cmap=colormap('jet'); %change for other colormaps
for i=1:size(X,1)
    for j=1:size(X,2)
        colors(i,j,:)=cmap(round(intensity(i,j)*(size(cmap,1)-1)+1),:);     
    end
end
%plot
hold on
for i=1:size(X,1)
    for j=1:size(X,2)
       plot3(X(i,j),Y(i,j),Z(i,j),'.','Color',colors(i,j,:));  
    end
end
hold off

在此处输入图像描述

于 2013-04-16T08:16:51.183 回答