フィルターのクリア

Calculating the area related to a specific color in colormap

3 ビュー (過去 30 日間)
Maryam
Maryam 2023 年 6 月 26 日
回答済み: DGM 2023 年 6 月 26 日
how to calculate the area of only the grey zone (less than 0.5) of this colormap?
  2 件のコメント
DGM
DGM 2023 年 6 月 26 日
It would probably be a lot more sensible to start from the data instead of trying to disassemble a figure to get the data back again.
Maryam
Maryam 2023 年 6 月 26 日
thanks so much for your response. Do you mind elaborating more?

サインインしてコメントする。

回答 (1 件)

DGM
DGM 2023 年 6 月 26 日
You might want to double check this.
openfig figure1.fig;
hp = get(gca,'children');
% CData in this case is 121834x3
% that is one color for each vertex of 121834 triangles
% the rendered color is interpolated linearly from the vertices
C = hp.CData;
% for the purposes of demonstration, i'm going to just assume
% that faces with _average_ vertex CData < 0.5 are to be selected
faceinROI = mean(C,1)<0.5;
% get only those selected faces
faces = hp.Faces(faceinROI,:);
% calculate the sum of the areas of those triangles
a = hp.Vertices(faces(:,2),:) - hp.Vertices(faces(:,1),:);
b = hp.Vertices(faces(:,3),:) - hp.Vertices(faces(:,1),:);
c = cross(a,b,2);
totalarea = 1/2 * sum(sqrt(sum(c.^2, 2)))

カテゴリ

Help Center および File ExchangeColormaps についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by