I'm using imcontour
in MATLAB 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?
The good news is that your data are already grouped. Assuming you have an image/matrix I
and you are doing something like imcontour(I, 2)
, you have just to use [C, h] = imcontour(I, 2)
.
C
is a ContourMatrix
, which contains (type help clabel
) the "contour line definitions, returned as a two-row matrix. Each contour line in the plot has an associated definition. If there are a total of N
contour lines in the plot, then the contour matrix consists of N
definitions (N=2
in your example):
C = [C(1) C(2)...C(k)...C(N)]
Each contour line definition follows this pattern:
C(k) = [level x(1) x(2) ... x(numxy)
numxy y(1) y(2) ... y(numxy) ]