X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 29 Aug 2011 04:05 PM by  anon
using masks in ENVI programming
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
29 Aug 2011 04:05 PM
    Hi folks - I am building in some error checking in ENVI/IDL code. I use band math to perform calculations over an entire image, where I am only interested in a subset of the entire image (I use an EVF file early on in the processing to determine values that will be later on applied to the whole image via band math). I would like to, effectively, use the EVF file as a mask over which to see if my processing results fall within a certain range of values. How do I apply an EVF file or ROI in ENVI scripting? Ie, 'If b1 is in the EVF file and is a certain value, where are those pixels', is what I want to know. thank you!

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    31 Aug 2011 07:31 AM
    This is a little more complicated. You could subset the image by a vector or ROI using RESIZE_DOIT. Then create a mask from the vectors/ROI, apply the mask to mask the values outside of the boundary, and then do a WHERE on the remaining pixels that are not masked. I have a sample program that would do the resize and masking that uses some undocumented routines. You would need to add in the code for WHERE that will find the indices of the pixels that meet the criteria 'of a certain value'. ========= pro subset_by_evf compile_opt idl2 ;select input file to subset fname = 'C:\Program Files\ITT\IDLxx\products\envixx\data\world_dem' envi_open_file, fname, r_fid=fid if (fid[0] eq -1) then return envi_file_query, fid, bnames=bnames, sname=sname ;open vector file to use for subset and get id evf_fname = 'C:\Program Files\ITT\IDLxx\products\envixx\data\vector\states_.evf' envi_check_save, /vector evf_open, evf_fname, vec=vec, /no_warning evf_id = vec.id ;compute the spatial boundary based on the evf using ROI routines roi_ids = envi_get_roi_ids(fid=fid, /include_evfs) ; this is an undocumented routine that finds the bondaries of an ROI and populates the DIMS array envi_roi_compute_spatial_boundry, roi_ids, dims, fid=fid ;resize the original image by the new dimensions envi_doit, 'resize_doit', fid=fid, dims=dims, pos=pos, $ rfact=[1.,1.], /in_memory, r_fid=sub_fid envi_file_query, sub_fid, ns=ns, nl=nl, dims=dims ;generate a mask from the evf - undocumented routine to generate a mask envi_mask_doit, evf_id=evf_id, evf_fid=sub_fid, ns=ns, nl=nl, and_or=0, $ /inside, /in_memory, r_fid=m_fid ;apply the mask to the subset image, setting background pixels to -9999 (or whatever you like depending on the data type) out_name=sname+'_subset' envi_mask_apply_doit, fid=sub_fid, pos=pos, dims=dims, m_fid=m_fid, m_pos=0l, $ value=-9999, out_bname=bnames, out_name=out_name ;close in memory files envi_file_mng, id=m_fid, /remove envi_file_mng, id=sub_fid, /remove envi_evf_close, evf_id end
    You are not authorized to post a reply.