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

Home » Public Forums » archive » Objects in ENVI ROI files
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: Objects in ENVI ROI files [message #84526 is a reply to message #84302] Mon, 20 May 2013 22:08 Go to previous messageGo to previous message
Josh Sixsmith is currently offline  Josh Sixsmith
Messages: 13
Registered: December 2012
Junior Member
Considering that the original post was back in 2006, it has probably already been solved.

Anyway, here is one method that should achieve what you're after.

Rather than use region_grow to find all of the values. Use a dummy array of the same x/y dimensions as to what the ROI is based off, and label it. This will be similar (if not the same as) to the region grow method, without the iterations.

You can use the roi addresses to index the dummy array and set the value to one (all other pixels should be zero).
Then use label_region. This will give each of your roi polygons a unique identifier.
The next step would be to find all the unique labels, using a combination of uniq and sort.
Use the histogram function and reverse indices. This can then be used to index the original array and do whatever you want, such as assign a new value, or calculate some stats.

The bins of interest are defined by the unique labels, which are also sorted. We know that the background is zero so ignore it when looping over the bins.

Eg:
dummy = bytarr(samples,lines)
dummy[roi_addr] = 1
label_arr = label_region(dummy)
labels = label_arr[uniq(label_arr, sort(label_arr))]
hist = histogram(label_arr, min=0, max=max(labels), reverse_indices=ri)

for i=1,n_elements(labels)-1 do begin
if hist[labels[i]] eq 0 then continue
;retrieve the data from the original array
polygon = orig_data[ri[ri[labels[i]]:ri[labels[i]+1]-1]]
;do something
endfor

That should get the individual polygons within each ROI that you’re after.

Cheers
Josh
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FG Save method -- Gifs
Next Topic: data with number of columns variables

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

Current Time: Wed Oct 08 15:56:43 PDT 2025

Total time taken to generate the page: 0.00466 seconds