How can I grab the contour lines into a new figure ?

9 Ansichten (letzte 30 Tage)
Uni
Uni am 7 Jun. 2013
I am using contour function to get the contour lines from an image. Now I'd pretend to get only the contour lines created before to make a new image.
I am using [C,h]=contour(a,[0 0]); I have C - ContourMatrix and h - handler.
How can I create a new image (only contour lines) with this C and h ??
Thanks in Advance Mike

Akzeptierte Antwort

Kelly Kearney
Kelly Kearney am 7 Jun. 2013
Easiest way: download contourcs, which will parse the C matrix for you.
a = peaks;
C = contourcs(a, [0 0]);
xy = {C.X; C.Y};
plot(xy{:});
  9 Kommentare
Kelly Kearney
Kelly Kearney am 11 Jun. 2013
Oops, forgot that one... imshow also flips the axis. Add 'ydir' to the list of properties to copy.
Uni
Uni am 12 Jun. 2013
Many many thanks :D

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Angus
Angus am 7 Jun. 2013
Try checking out ContourMatrix.
"ContourMatrix is also a read-only contourgroup property that you can obtain from the returned handle." -- matlab docs
  1 Kommentar
Uni
Uni am 8 Jun. 2013
you mean I should rearrange my C variable from contour function to get the new image ?
thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Contour Plots finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by