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

Home » Public Forums » archive » how to convert a segmented image to _polygons_ and save it in a single ROI or .evf file?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
how to convert a segmented image to _polygons_ and save it in a single ROI or .evf file? [message #88119] Fri, 21 March 2014 08:00
mz is currently offline  mz
Messages: 1
Registered: March 2014
Junior Member
Hi,

I have a segmented image where each segment has a unique label (say 1,...,n), where my n is typically > 10,000. I would like to convert the segments to polygons (not single points) and save the polygons in a single ROI (or .evf file, if easier). Please, do you have suggestions?

I tried several thing without success.

For instance, using CONTOUR to get the segment borders, but apparently CONTOUR does not produce closed polygons like I was hopping. For instance:

a = bytarr(6,5)
a[1,2] = 1
a[1,3] = 1
a[2,1] = 1
a[3,2] = 1
a[4,3] = 1
a[4,2] = 1

CONTOUR, a, level = 1, XMARGIN=[0,0], YMARGIN=[0,0], PATH_INFO=pathInfo, PATH_XY=pathXY, XSTYLE=5, YSTYLE=5, /PATH_DATA_COORDS

print, a
0 0 0 0 0 0
0 0 1 0 0 0
0 1 0 1 1 0
0 1 0 0 1 0
0 0 0 0 0 0

print, pathXY
3.00000 2.00000
4.00000 3.00000
4.00000 2.00000

My hope with COUNTOUR was to use it like this:

xpts = REFORM([[pathXY[0,*]],[pathXY[0,0]]])
ypts = REFORM([[pathXY[1,*]],[pathXY[1,0]]])

.... loop all segments ...
roi_id = envi_create_roi(color=roi_color, ns=ns, nl=nl, name=name)
envi_define_roi, roi_id, /polygon, /no_update, xpts=xpts, ypts=ypts
....

roi_ids = envi_get_roi_ids(roi_names=roi_names, /short_name,roi_colors=colors)
envi_save_rois, 'myname.roi', roi_ids

Alternatively, I tried using the 'rtv_doit'

envi_doit, 'rtv_doit', $
fid=fid, pos=pos, dims=dims, $
values=values, l_name=l_name, $
in_memory=in_memory, $
out_names=out_names

but if I set 'in_memory' = 0, I have to save thousands of .evf files on disk, this is very slow. If 'in_memory' = 1, than I don't know how to access each segment 'in memory' for further processing.

Any suggestion is very welcome! Thank you!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: CV_Coord function
Next Topic: Transparent series of images with axis using cgImage

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

Current Time: Wed Oct 08 11:54:02 PDT 2025

Total time taken to generate the page: 0.00497 seconds