Re: How to edit the file of classification [message #66867] |
Fri, 12 June 2009 04:48 |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
mengran wrote:
> Hi, everyone.
>
> I want to open and edit a envi standard classification file in IDL.
> But I don not know using which function to open it ,and then get the
> data into a variable to edit it, finally save the edited data as a
> envi standard classification file.
>
> Could you please help me ? Thanks a lot!
>
> best wishes!
>
> mengran
Hi Mengran,
you can do something like this, provided you have Envi.
envi, /restore_base_save_files
envi_batch_init
;Open the file in envi
ENVI_OPEN_FILE, fileToOpen, /NO_REALIZE , R_FID=FID
;Read the header
envi_file_query, fid, ns=dimX, nl=dimY, nb=nbBands, $
DATA_TYPE=dataType, OFFSET = HeaderOffSet, $
LOOKUP= lookup, class_names = classNames, $
num_classes = numClasses
map_Info = ENVI_GET_MAP_INFO(FID=FID)
headerInfo = {ns:dimX, nl:dimY, lookup:lookup, $
map_info:map_Info, class_names:classNames, $
num_classes:numClasses}
;Read the data in IDL
data = read_binary(fileToOpen,data_Start = HeaderOffSet, $
data_Type=dataType, data_Dims=[dimX,dimY],ENDIAN = "native")
;Do something on your data
;Save your file (check the nb.. you may want to read it from the file,
in the header structure)
ENVI_WRITE_ENVI_FILE, data, data_type=dataType, nb=1, nl=headerInfo.nl,$
ns=headerInfo.ns,OUT_NAME = outFilName, $
BNAMES = 'modified band', class_names = headerInfo.class_names, $
lookup=headerInfo.lookup, map_info=headerInfo.map_info, $
num_classes = headerInfo.num_classes
Jean
|
|
|