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!
|