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 #90506 is a reply to message #84526] Thu, 05 March 2015 10:02 Go to previous messageGo to previous message
samsammurphy is currently offline  samsammurphy
Messages: 2
Registered: March 2015
Junior Member
On Tuesday, May 21, 2013 at 2:08:47 AM UTC-3, Josh Sixsmith wrote:
> 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

Thanks for posting this. It is what I was looking for - looks like its a subject that comes around every few years :)
[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: Thu Oct 09 04:27:12 PDT 2025

Total time taken to generate the page: 0.24341 seconds