How to group the green contour and the yellow contour?

2 ビュー (過去 30 日間)
cliffy
cliffy 2018 年 10 月 10 日
コメント済み: cliffy 2018 年 10 月 12 日
I'm using "imcontour" to get the contour of some image. The resulting image is as follow. Is there any way that I can pick out the green contour together as a group, and the yellow contour together as a group?

採用された回答

jonas
jonas 2018 年 10 月 10 日
編集済み: jonas 2018 年 10 月 10 日
Sure, the first output of the imcontour, just like any other contour plot, is a contour matrix . If you understand its structure, then it's quite easy to extract the individual levels. If you upload the image and code I might give it a try.
Here is another question where I first had to parse the contour matrix.
  5 件のコメント
jonas
jonas 2018 年 10 月 12 日
Sure, here is an example. The contours are stored in out and their levels are stored in lvls.
%%Some data
t=1:100;
y=1:100;
z=peaks(100);
%%Get contours
C=contour(t,y,z,'levellist',[2 3]);
cnt=[0];nc=[];idc=[];
while (sum(nc)+cnt)<size(C,2)
cnt=cnt+1;
idc=[idc sum(nc)+cnt];
nc=[nc C(2,idc(end))];
end
%%Save levels and remove the corresponding cols
lvls=C(1,idc);
for j=1:length(idc)-1
out{j} = C(:,idc(j)+1:idc(j+1)-1);
end
cliffy
cliffy 2018 年 10 月 12 日
Thank you for the help! It's a nice idea to store matrix in cell. I got it.

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

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by