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

Home » Public Forums » archive » Re: ENVI CLASSIFICATION (explained)
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
Re: ENVI CLASSIFICATION (explained) [message #60768] Wed, 04 June 2008 07:30
jeffnettles4870 is currently offline  jeffnettles4870
Messages: 111
Registered: October 2006
Senior Member
On Jun 4, 4:41 am, Kostas <ko...@freemail.gr> wrote:
> Thank you all for your reply.
>
> I am sure that i didnt explain exactly what i ask.
> sorry about it but my english are not so good.
>
> 1.Lets suppose that i have an image named im1.img
> 2. lets suppose that i want to classify this image using K-MEANS
>
> from envi i choose menu classification->unsupervised->K-Means
> I choose the file (all the bands) and then i have the K-Means
> classification window.
>
> 3. Lets suppose that i execute the algorithm with NUMBER of CLASSES=4
>
> What i am asking is: Is it possible to export each class as ROI's
> Programatically
>
> Thank you
>
> Kostas

A classification image is just an image with each pixel's value set to
the number of the class it was assigned to. So for your image you
should be able to find exactly 4 values in your image: 0,1,2, & 3.
You want to loop over these values and with each iteration select all
the pixels in the image having the current class number (given by the
looping variable), and turn that into an ROI.

With Pete's suggestion, you just want to call the envi 'doit' inside
the loop, using the min & max keywords to select the right pixels, so
it would look something like this:

for i = 0,3 do begin
ENVI_DOIT, 'ROI_THRESH_DOIT', fid=fid, pos=pos, dims=dims, $
min_thresh=i, max_thresh=i, /no_query, roi_color=roi_color, $
roi_name=roi_name, roi_id=roi_id

;add this if you want to save the ROI to a file
envi_save_rois, out_name, roi_id
endfor

All the keywords to roi_thresh_doit you will have had to set before
the loop (other than min_thresh and max_thresh).

I personally prefer to have more flexibility in my code so i would've
done this a little differently. My loop would look something like
this (and i'm going to write pseudcode since i just realized i have a
meeting in 5 min):

for i = 0,3 do begin
1. select pixels in the image with WHERE().
2. call ARRAY_INDICES() on output of 1 to get x and y coords
3. call ENVI_CREATE_ROI() to specify ROI name, colors, etc.
4. add points to my ROI with ENVI_DEFINE_ROI
5. save ROI if needed (ENVI_SAVE_ROIS)
endfor

My suggestion: if you want something quick use Pete's method, if you
want something you can come back to and modify later, use mine.

Jeff
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: ENVI CLASSIFICATION (explained)
Next Topic: interpolation problems in 2d and/or 3d space

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

Current Time: Wed Oct 08 17:39:35 PDT 2025

Total time taken to generate the page: 0.00528 seconds