X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 16 Nov 2011 05:47 AM by  anon
unsupervised classification of hyperspectral data?
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
16 Nov 2011 05:47 AM
    Hi there, I am trying to write a script that will run an unsupervised classification (ISODATA) over a bunch of images and I can't seem to find the IDL routine for the isodata unsupervised classification. I tried searching this forum and the IDL help section for classification, isodata, unsupervised and didnt get anything. I would also like to use .pix files if possible. I can open the .pix files but i cant view them yet... Suggestions are welcome. thanks.

    Deleted User



    New Member


    Posts:
    New Member


    --
    16 Nov 2011 08:08 AM
    IDL itself doesn't have a routine to perform an isodata unsupervised classification of imagery. There is a routine to do it in ENVI batch mode, though, if you have access to an ENVI license. In ENVI you would use the CLASS_DOIT routine with the METHOD keyword set to 4. Maybe you could program the isodata algorithm yourself in IDL? You can find the algorithm in this reference: Tou, J. T. and R. C. Gonzalez, 1974. Pattern Recognition Principles, Addison-Wesley Publishing Company, Reading, Massachusetts. - Peg

    Deleted User



    New Member


    Posts:
    New Member


    --
    17 Nov 2011 02:50 AM
    Hi Peg, Thank you so very much! I have access to an ENVI license, so I will try the CLASS_DOIT This is absolutely perfect because I need to write a script for SAM classifications too. If I had more time I would like to try and implement the algorithm myself! Thanks again. -nola

    Deleted User



    New Member


    Posts:
    New Member


    --
    17 Nov 2011 05:15 AM
    Thanks to Peg and the wonders of google, I was able to put together a script that uses 3 bands (NIR,Blue,Green) to unsupervise class via isodata on a small subset of my study area. i still need to test it on my big area but that will take many hours, so i will report back when that is fully done! This script will look into a folder where all your input images are and process them all using the isodata method. i am only concerned with land and water so this scripts works fine me. i I figured i would share in case someone else needs something like this. there is a few extra lines of code that are not really needed but i left it in as it taught me how to do things a bit better. documentation for later you can call it. the only thing i need now is to figure out how to apply a mask to my big images... cheers. nola ;--------------------------------------------------------------------------- forward_function ENVI_OPEN_FILE, ENVI_BATCH_INIT ; script to batch classify using isodata to create land masks ; ;--------------------------------------------------------------------------- ;NEED THIS OR CODE WONT WORK ;First restore all the base save files. envi, /restore_base_save_files ; Initialize ENVI and send all errors and warnings to the file batch.txt envi_batch_init, log_file= 'G:\casi\00idlTest\batch.txt' ;--------------------------------------------------------------------------- ;hardcode input and output folders for data and mask files datin = 'G:\casi\00idlTest\dat' maskin = 'G:\casi\00idlTest\mask' datout = 'G:\casi\00idlTest\results' ;input data extension and output name datext = '*.pix' out_name=datout+'\test.pix' ;returns all the filenames into an array datfiles = file_search(datin, datext) ;maskfiles = file_search(maskin, datext) ;print, datfiles ;print, maskfiles ;2 methods to return the number of files in the array ;q=n_elements(datfiles) ;elegant method ;not so elegent method z=size(datfiles) numFiles = z[1] ;print,'There are ', numFiles, ' files in the input folder.' ;opens, reads and isodata class all the data images in ENVI for i = 0, n_elements(datfiles)-1 do begin filename = datfiles[i,0] ; Open the input file in ENVI envi_open_file, filename, r_fid=fid if (fid eq -1) then begin envi_batch_exit return endif ; Get the spatial dimensions and # of bands for the input file. envi_file_query, fid, dims=dims, nb=nb ;ENVI ISODATA classification ENVI_DOIT, 'class_doit', fid=fid, pos=[24,13,8], dims=dims,$ out_bname='ISOData_test', out_name=out_name, method=4, $ r_fid=r_fid, iterations=1, change_thresh = 0, iso_merge_dist= 1, $ iso_merge_pairs=3, iso_min_pixels=50, iso_split_smult=1, $ iso_split_std=0, min_classes=5, num_classes=7, in_memory=0 endfor ;envi_batch_exit end
    You are not authorized to post a reply.