X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 01 Oct 2013 11:51 PM by  anon
problem with 'envi_convert_file_coordinates'
 4 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
01 Oct 2013 11:51 PM
    I was trying to classify the same image at different resolutions. Thus, I have to resample the image use envi_doit, 'RESIZE_DOIT' fisrst. The problem was how to trandfer thetraining data from one image to another, and this could be easily realized in ENVI using reconcile rois via map, and I need to perform it in envi batch mode, and I found the answer at the site: http://www.exelisvis.com/Support/Foru... But I got some problem with ‘envi_convert_file_coordinates’procedure, when I set the resize factor:[xfac=1,yfac=1], the pixel in the converted new roi doesn’tmatch the original one. Here are some source code from my project. ; Delete any unwanted ROIs envi_delete_rois, roi_ids envi_restore_rois, 'image_rois.roi' roi_ids = envi_get_roi_ids(fid=fid, $ roi_colors=roi_colors, $ roi_names=class_names) ;get all the ROI addresses from the first image re_roi_id = lonarr(n_elements(roi_ids)) re_roi_name = ['target','bkground'] fori=0, n_elements(roi_ids)-1 do begin roi_pxAdd = envi_get_roi(roi_ids[i], $ roi_color=roi_colors, $ roi_name=roi_names) envi_convert_file_coordinates, fid, roi_pxAdd/ns, roi_pxAdd mod ns,XMap, YMap, /TO_MAP envi_convert_file_coordinates, r_fid, xF, yF, xMap, yMap envi_file_query, r_fid, dims=r_dims, ns=r_ns, nl=r_nl, nb=r_nb,bnames=r_bnames roi_id = envi_create_roi(color=i+2, name=re_roi_name[i], ns=r_ns,nl=r_nl) envi_define_roi, roi_id, /polygon, xpts=XF, ypts=YF re_roi_id[i] = roi_id endfor roi_filename = 'image_rois_resized.roi' envi_save_rois, roi_filename, re_roi_id In desperate need of help, thanks a lot!!!

    Berangere Casson



    New Member


    Posts:61
    New Member


    --
    02 Oct 2013 03:27 AM
    Could you identify if the output from the following code line is correct or not: envi_convert_file_coordinates, fid, roi_pxAdd/ns, roi_pxAdd mod ns,XMap, YMap, /TO_MAP It would help understanding which command in the code does not output the expected result.

    Deleted User



    New Member


    Posts:
    New Member


    --
    02 Oct 2013 06:48 AM
    I am sorry, i didn't got what you have written above. I tried to modify the code as envi_convert_file_coordinates, fid, roi_pxAdd mod ns, roi_pxAdd/ns, XMap, YMap, /TO_MAP but it still doesn't present the expected result.

    Berangere Casson



    New Member


    Posts:61
    New Member


    --
    03 Oct 2013 03:44 AM
    I was not thinking about looking at/analyzing the output coordinates (xMAP,yMAP) from the following lines of code envi_convert_file_coordinates, fid, roi_pxAdd mod ns, roi_pxAdd/ns, XMap, YMap, /TO_MAP or envi_convert_file_coordinates, fid, roi_pxAdd/ns, roi_pxAdd mod ns,XMap, YMap, /TO_MAP And trying to check if these output map coordinates are correct or not. Indeed if the map coordinates are not correct the output pixel coordinates from the next line of code will be wrong too. envi_convert_file_coordinates, r_fid, xF, yF, xMap, yMap

    Deleted User



    New Member


    Posts:
    New Member


    --
    03 Oct 2013 10:36 AM
    Thanks a lot. I find real problem is not envi_convert_file_coordinates, but envi_create_roi, envi_define_roi and envi_save_rois. I have a roi file containing two roi regions, and each roi have several parts(or polygons) I used the following code to read the roi data from the roi file and then write it back, the roi regions changed! Here are some code from my project envi_restore_rois, 'origin.roi' roi_ids = envi_get_roi_ids(fid=fid, $ roi_colors=roi_colors, $ roi_names=roi_names, $ /short_name) ; get all the ROI addresses from the first image r_roi_ids = lonarr(n_elements(roi_ids)) for i=0, n_elements(roi_ids)-1 do begin roi_addr = envi_get_roi(roi_ids[i], $ roi_color=rcolor, roi_name=rname) yf = roi_addr / ns xf = roi_addr mod ns r_roi_id = envi_create_roi(color=i+2, $ name=roi_names[i], $ ns=r_ns, nl=r_nl) envi_define_roi, r_roi_id, /polygon, xpts=xf, ypts=yf r_roi_ids[i] = r_roi_id endfor envi_save_rois, 'new_generated.roi', r_roi_ids
    You are not authorized to post a reply.