Re: contourc and length of contours



"mark b." <john.doe.nospam@xxxxxxxxxxxxx> wrote in message <g1s6ml
$bl1$1@xxxxxxxxxxxxxxxxxx>...
hi,
i've got a question about 'contourc' function. do i
understand corectly that this function should compute
lenght of conturs?
i've got set of points (x,y) of contour. and i want to know
it's length. but when i use 'contourc' function i get
matrix 2xN, with values i do not understand. i read matlab
documentation but i do not understand how to callculate
this lenght.
can anyone help me with that??
kind regards
------------
That 2 x N matrix you receive from 'contourc' is supposed to contain all the
x,y data along the various contours placed end-to-end. To find their lengths
you need to extract the data for each contour separately and sum the
distances of successive point pairs. To do so will undoubtedly require the
use of a while-loop.

Suppose there are only two contours, one at level L1 and the other at level
L2. Suppose the first contour has three points (x1,y1), (x2,y2), and (x3,y3).
Suppose the second contour has two points (x4,y4) and (x5,y5). Then C the
output of 'contourc' would be the 2 x 7 array:

C = [L1 x1 x2 x3 L2 x4 x5;
3 y1 y2 y3 2 y4 y5];

Your task would be to sort out the first three points and compute

sqrt((x2-x1)^2+(y2-y1)^2)+sqrt((x3-x2)^2+(y3-y2)^2)

and then the second two points and compute

sqrt((x5-x4)^2+(y5-y4)^2)

which would be the two respective contour lengths. This example together
with another reading of the documentation should enable you to understand
the general format of 'contourc' outputs.

My understanding is that 'contourc' is regarded as a "low-level" routine and
consequently its output is relatively user-unfriendly. Confession: I haven't
actually used 'contourc' so the above is all based on my reading of the
documentation. (However, the documentation for my earlier system seems
clearer than the up-to-date one on the internet.) You had better check it out
carefully for yourself.

Note that summing the lengths of successive line segments is only an
approximation to true contour lengths but it is probably the best you can do
with the discrete data given - that is, unless you want to get into spline fits or
the like.

Roger Stafford


.