comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Edge detection and convert edges into polygons
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Edge detection and convert edges into polygons [message #61899] Mon, 04 August 2008 00:50 Go to previous message
M. Suklitsch is currently offline  M. Suklitsch
Messages: 12
Registered: August 2008
Junior Member
Hi!


Thanks for the quick replies!

Paolo, I have several subregions, defined over a specific area. These
subregions are sometimes bigger (> 100 pixels), sometimes only consist
of three or four pixels. And yes, I want to find out in which of these
subregions my station, or more general a point of interest, lies.

David, this is what I've come up with thanks to your hints. Although
this code works, maybe there is some shortcut that makes the whole
thing even better?


FOR mm = 1, iNumOfRegs-1 DO BEGIN
; do some edge detection in rgiGridMsk
rgiIndices = WHERE(rgiGridMsk EQ mm)
IF rgiIndices[0] NE -1 THEN BEGIN
rgiBoundary = Find_Boundary(rgiIndices,$
xsize=rgiGridSiz[0],ysize=rgiGridSiz[1])

rgrXVect = FLTARR(N_ELEMENTS(rgiBoundary)/2) & rgrYVect =
rgrXVect

; now get the corresponding lat/lon values and store them as
vectors
FOR nn = 0, N_ELEMENTS(rgiBoundary)/2 -1 DO BEGIN
rgrXVect[nn] =
rgrGridLon[rgiBoundary[0,nn],rgiBoundary[1,nn]]
rgrYVect[nn] =
rgrGridLat[rgiBoundary[0,nn],rgiBoundary[1,nn]]
ENDFOR

; put the polygons into IDLanROI object
grROI = OBJ_NEW('IDLanROI', rgrXVect, rgrYVect)

; use IDLanROI->ContainsPoints to check whether stations lie
; within or without a region
rgiMatch = grROI->ContainsPoints(rgrLon,rgrLat)
iFoundMatch = (WHERE(rgiMatch NE 0))[0]
IF iFoundMatch NE -1 THEN BEGIN
rgiStationMaskIdx[WHERE(rgiMatch NE 0)] = mm
ENDIF
ENDIF
ENDFOR

Maybe a short explanation: rgrLon and rgrLat are vectors holding the
longitude and latitude of several points of interest,
rgiStationMaskIdx is a vector of the same size as rgrLon where the
corresponding subregion index is stored.


Cheers,
Martin


David Fanning schrieb:
>
> I think I would just work with the integer mask and find
> the boundaries around the sub-regions:
>
> http://www.dfanning.com/ip_tips/boundary.html
>
> You can use the boundary directly to create an IDLanROI
> object, or (probably a good idea) you can reduce the
> number of vertices in the boundary with MESH_DECIMATE
> first.
>
> 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.")
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Piecewise curve fitting in idl
Next Topic: Re: Printing multiple columns in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 22:34:51 PDT 2025

Total time taken to generate the page: 0.72091 seconds