X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 18 Mar 2009 02:53 PM by  anon
generating a mask from an ROI in IDL, and then apply over an image.img
 1 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
18 Mar 2009 02:53 PM
    Hi all, I´m trying to generate a mask from an region of interest ROI in IDL, and then apply over an image.img, From an vector, I generate the ROI (in ENVI) exporting active layer to roi (one ROI), then I save the ROI. I generate the mask from a “region of interest.roi”, the code works, but doit wrong, because the mask generated with the roi have diferent numbers of files and columns that the original image, then the image masked had a wrong size. I attach the code in the bottom, pro example_envi_roi_to_image_doit  ;  ; 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='f:\working\batch.txt'  ;  ; Open the input file associated with  ; the ROIs  ;  envi_open_file, 'c:\javier\borrar\image.img', r_fid=fid  if (fid eq -1) then begin  envi_batch_exit  return  endif  ;  ; Restore the ROI file and get all  ; the available ROI ids.  ;  envi_restore_rois, 'c:\javier\vectores\region_of_interest.roi'  roi_ids = envi_get_roi_ids()  if (roi_ids[0] eq -1) then return  ;  ; Set the necessary variables  ;  class_values = lindgen(n_elements(roi_ids))+1  ;  ; Call the doit  ;  out_name2 = 'c:\javier\borrar\mask_javier'  envi_doit, 'envi_roi_to_image_doit', $  fid=fid, roi_ids=roi_ids, out_name=out_name2, $  class_values=class_values   ENVI_select, fid=fid2 ENVI_FILE_QUERY, fid, NS = ns, NL = nl, NB = nb   ; Set the keyword parameters m_dims = [-1L, 0, ns - 1, 0, nl - 1] pos = LINDGEN(nb) m_pos = [0] out_name3='c:\javier\borrar\mask_aplicada.img ; Call the 'doit' ENVI_MASK_APPLY_DOIT, fid = fid, POS = pos, DIMS = m_dims, $    M_FID = fid2, M_POS = m_pos, VALUE = 0, OUT_NAME = out_name3, $    IN_MEMORY = 0, R_FID = r_fid    ;Exit ENVI  ;envi_batch_exit end   I´m making something bad about the generation of the mask, somebody can help me? thanks in advance, Javier.

    MariM



    Veteran Member


    Posts:2396
    Veteran Member


    --
    23 Mar 2009 10:47 AM
    What error did you get?  I don't understand why the mask would have different dimensions from the original file since the ROIs were derived from the original image, yes?  The ROIs are based on the dimensions of the image from which they were created so when you create the 'mask' image from the ROIs, the mask should have the same dimensions as the image.  I ran your code on our sample dataset bhtmref.img and a single ROI I created and it ran without error. 
    You are not authorized to post a reply.