Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
In article <9b50eb9a-33ea-40a2-8e0a-5e7e92bf52a8@x35g2000hsb.googlegroups.com>, "mzagursk@gmail.com" <mzagursk@gmail.com> wrote: > Hi, > > I've got a 2d map (let's say it's a contour map of a mountain). I > need to be able to 'detect' and 'follow' the ridgeline across the > whole mountain (which does about a 180 degree turn as well, it's U > shaped). Anyone know any way to accomplish this? > > So far, i've attempted to start at the maximum point, and then look > for surrounding points that minimizes the downward slope, this > process, however, creates switchbacks at peaks and doesnt follow the > peak down along a ridge. Any ideas? > > Thanks! You could look for the maximum curvature of the contour lines. It might be necessary to add some non-artificial intelligence to get the final result the way you want. Ken Bowman
mzagursk@gmail.com writes: > I've got a 2d map (let's say it's a contour map of a mountain). I > need to be able to 'detect' and 'follow' the ridgeline across the > whole mountain (which does about a 180 degree turn as well, it's U > shaped). Anyone know any way to accomplish this? > > So far, i've attempted to start at the maximum point, and then look > for surrounding points that minimizes the downward slope, this > process, however, creates switchbacks at peaks and doesnt follow the > peak down along a ridge. Any ideas? The obvious idea is the WATERSHED function. Have you tried that? Cheers, David -- David Fanning, Ph.D. Fanning Software Consulting, Inc. Coyote's Guide to IDL Programming: http://www.dfanning.com/ Sepore ma de ni thui. ("Perhaps thou speakest truth.")
On Jun 16, 12:49 pm, David Fanning <n...@dfanning.com> wrote: > mzagu...@gmail.com writes: >> I've got a 2d map (let's say it's a contour map of a mountain). I >> need to be able to 'detect' and 'follow' the ridgeline across the >> whole mountain (which does about a 180 degree turn as well, it's U >> shaped). Anyone know any way to accomplish this? > >> So far, i've attempted to start at the maximum point, and then look >> for surrounding points that minimizes the downward slope, this >> process, however, creates switchbacks at peaks and doesnt follow the >> peak down along a ridge. Any ideas? > > The obvious idea is the WATERSHED function. Have you > tried that? > > Cheers, > > David > -- > David Fanning, Ph.D. > Fanning Software Consulting, Inc. > Coyote's Guide to IDL Programming:http://www.dfanning.com/ > Sepore ma de ni thui. ("Perhaps thou speakest truth.") Yes, but I'm not sure how to implement it in such a way to output the ridge. This 'image' is simply a background of 0's with a single ridgeline rising out of it. When I use watershed, it give me bogus answers, lines that make no sense at all.
On Jun 16, 1:15 pm, "mzagu...@gmail.com" <mzagu...@gmail.com> wrote: > On Jun 16, 12:49 pm, David Fanning <n...@dfanning.com> wrote: > > > >> mzagu...@gmail.com writes: >>> I've got a 2d map (let's say it's a contour map of a mountain). I >>> need to be able to 'detect' and 'follow' the ridgeline across the >>> whole mountain (which does about a 180 degree turn as well, it's U >>> shaped). Anyone know any way to accomplish this? > >>> So far, i've attempted to start at the maximum point, and then look >>> for surrounding points that minimizes the downward slope, this >>> process, however, creates switchbacks at peaks and doesnt follow the >>> peak down along a ridge. Any ideas? > >> The obvious idea is the WATERSHED function. Have you >> tried that? > >> Cheers, > >> David >> -- >> David Fanning, Ph.D. >> Fanning Software Consulting, Inc. >> Coyote's Guide to IDL Programming:http://www.dfanning.com/ >> Sepore ma de ni thui. ("Perhaps thou speakest truth.") > > Yes, but I'm not sure how to implement it in such a way to output the > ridge. This 'image' is simply a background of 0's with a single > ridgeline rising out of it. When I use watershed, it give me bogus > answers, lines that make no sense at all. Here's an image of what I'm talking about: http://www.mattzag.com/mountain_example.tiff I need to follow the long ridgeline and output those points. Thanks a bunch.
How about finding the maximum pixelvalue in the image, and then looking at the slope to a 4 pixel (or 6; 9) mean value for all the points at a specific distance (e.g., 30 pixels) away? Select the location with the lowest slope (Or maximum mean) and continue from there. That should give you a reasonable indication of the path that the ridge follows? Once you have the crude outline you can improve by searching within the interpixel path in a region of a few pixels wide for the best path to follow? You will need to allow for some maximum curvature in the slope (e.g. 90 deg lef / right) from the direction of the last two consecutive points to allow curving of the ridge, without backtracking. Also: Going uphill after N steps should be allowed, to allow for undulating ridgelines. But again: only within the curvature parameters? Jelle
Kenneth P. Bowman wrote: > You could look for the maximum curvature of the contour lines. > It might be necessary to add some non-artificial intelligence to > get the final result the way you want. As a keen hillwalker, orienteer and skier who often needs to do this it got me thinking... I think Ken's idea is probably a good way. One thing the nAI will particularly have to look for is gullies right next to the ridges which may have sharp contour curves too, but the other way. Perhaps check the direction of successive "arrowheads" against one another and make sure they haven't spun through too big an arc (180 degrees would certainly suggest you've Got It Wrong...). That might also be a way to decide which side of a bifurcation you'd follow. But I haven't got anything as useful as an algorithm that actually tells you /how/ :-( Pete. -- Peter Clinch Medical Physics IT Officer Tel 44 1382 660111 ext. 33637 Univ. of Dundee, Ninewells Hospital Fax 44 1382 640177 Dundee DD1 9SY Scotland UK net p.j.clinch@dundee.ac.uk http://www.dundee.ac.uk/~pjclinch/
On 16 Jun, 20:24, "mzagu...@gmail.com" <mzagu...@gmail.com> wrote: > Hi, > > I've got a 2d map (let's say it's a contour map of a mountain). I > need to be able to 'detect' and 'follow' the ridgeline across the > whole mountain (which does about a 180 degree turn as well, it's U > shaped). Anyone know any way to accomplish this? > > So far, i've attempted to start at the maximum point, and then look > for surrounding points that minimizes the downward slope, this > process, however, creates switchbacks at peaks and doesnt follow the > peak down along a ridge. Any ideas? > > Thanks! Have you tried to find the medial axis? The thin() function calculates this for you. Cheers, Richard.
Jelle wrote: > > How about finding the maximum pixelvalue in the image, and then > looking at the slope to a 4 pixel (or 6; 9) mean value for all the > points at a specific distance (e.g., 30 pixels) away? Select the > location with the lowest slope (Or maximum mean) and continue from > there. > Jelle Hum... an edge is not necessarily the lowest slope... What about edge detection filters? ... the Canny edge detector seems to be fairly good (I haven't used it myself though) http://en.wikipedia.org/wiki/Canny_edge_detector http://www.isprs.org/istanbul2004/comm3/papers/376.pdf fig 6A Jean
On Jun 17, 6:14 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca> wrote: > Hum... an edge is not necessarily the lowest slope... Agreed, but a ridge would be, wouldn't it? But possibly that is exactly the problem: When is a ridge a ridge. When that can be define propely, one can model a solution.
Jelle wrote: > On Jun 17, 6:14 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca> > wrote: >> Hum... an edge is not necessarily the lowest slope... > > Agreed, but a ridge would be, wouldn't it? hum.... let's think of a prism laying on the kitchen table: the top edge is a ridge, the slope of the ridge is zero and 2 "steep" plan lay on each side. Now let's put the prism on one of its triangle (and add a small angle). The same ridge is now almost vertical and the slope of the plans on each side is now smaller... > But possibly that is exactly the problem: When is a ridge a ridge. > When that can be define propely, one can model a solution. agreed... I like the "why programmers are lazy and dumb" link on your page.. it is indeed hard to solve a problem that can not be defined :-) Jean
As far as I can tell it seems that a ridge is normally if not always the tallest point in its local environment. If you scan the image on a going from the top row to the bottom row and get the maximum value in that row and report that back and then do the same from the first column to the last column and report those values back you have a decent outline of the ridge (meaning haven't tried it). It would be even more robust if you went through the image on 45 degree diagonals as well and report those back so that completely horizontal. Seems like it would work to me.
On Jun 18, 5:14 pm, Juggernaut <juggernau...@gmail.com> wrote: > As far as I can tell it seems that a ridge is normally if not always > the tallest point in its local environment. If you scan the image on > a going from the top row to the bottom row and get the maximum value > in that row and report that back and then do the same from the first > column to the last column and report those values back you have a > decent outline of the ridge (meaning haven't tried it). It would be > even more robust if you went through the image on 45 degree diagonals > as well and report those back so that completely horizontal. Seems > like it would work to me. problem is of course.. the ridge in general is the tallest ponts in the local area. Except for trenches and local dips :). Tha is why I suggested looking at mean levels a bit further away. hm.. getting to the point that a piece of paper and a pencil come out :)
On Jun 18, 4:55 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca> wrote: > I like the "why programmers are lazy and dumb" link on your page.. it is > indeed hard to solve a problem that can not be defined :-) > > Jean hehe, me too. For those who might like it but are not keen to see my personal site; it points to this site: http://blogoscoped.com/archive/2005-08-24-n14.html
Have a look at http://picasaweb.google.de/karo03de/Idl Left you see a distance transformed binary image a with the result of thin(a) in red, unluckily not exact and not connected, an error existant since the beginnings of idl. In fact thin is working on the binary image. The skeleton should correspond with the ridge lines of the distance transformed binary image! tvscl,a,0 tvscl,thin(a),0,chan=1 Right a possible result performed by my program, which is not easily to be transfered (dll and a bunch of software). mm_skeleton is a "real" grey scale skeleton, performed by succeeding hit-or-miss transformations. tvscl,a,1 tvscl,mm_skelton(a),0,chan=1,1 Mathematical morphology is the keyword for this! Watershed delivers just the contrary of what you are looking for! watershed borders are some sort of saddle points in the distance map. Regards Karsten Am Mon, 16 Jun 2008 22:34:20 +0200 schrieb mzagursk@gmail.com <mzagursk@gmail.com>: > On Jun 16, 1:15 pm, "mzagu...@gmail.com" <mzagu...@gmail.com> wrote: >> On Jun 16, 12:49 pm, David Fanning <n...@dfanning.com> wrote: >> >> >> >>> mzagu...@gmail.com writes: >>>> I've got a 2d map (let's say it's a contour map of a mountain). I >>>> need to be able to 'detect' and 'follow' the ridgeline across the >>>> whole mountain (which does about a 180 degree turn as well, it's U >>>> shaped). Anyone know any way to accomplish this? >> >>>> So far, i've attempted to start at the maximum point, and then look >>>> for surrounding points that minimizes the downward slope, this >>>> process, however, creates switchbacks at peaks and doesnt follow the >>>> peak down along a ridge. Any ideas? >> >>> The obvious idea is the WATERSHED function. Have you >>> tried that? >> >>> Cheers, >> >>> David >>> -- >>> David Fanning, Ph.D. >>> Fanning Software Consulting, Inc. >>> Coyote's Guide to IDL Programming:http://www.dfanning.com/ >>> Sepore ma de ni thui. ("Perhaps thou speakest truth.") >> >> Yes, but I'm not sure how to implement it in such a way to output the >> ridge. This 'image' is simply a background of 0's with a single >> ridgeline rising out of it. When I use watershed, it give me bogus >> answers, lines that make no sense at all. > > Here's an image of what I'm talking about: > http://www.mattzag.com/mountain_example.tiff > I need to follow the long ridgeline and output those points. Thanks a > bunch. -- Erstellt mit Operas revolutionï¿œrem E-Mail-Modul: http://www.opera.com/m2/
On Jun 17, 1:14 pm, Jean H <jghas...@DELTHIS.ucalgary.ANDTHIS.ca> wrote: > What about edge detection filters? ... the Canny edge detector seems > to be fairly good The first part of the Canny edge detector is the calculation of a gradient image. Then it follows gradient contours. With appropriate choice of the smoothing parameter, it aught to do fairly well. Mike