Post by s***@gmail.comPost by Jeff N.Post by s***@gmail.comGood day
i did excercise from ENVI Programming documentation with ROI. from
ENVI i create 4 different ROIs.
then i use ENVI_GET_ROI_DATA function i get values of my ROI pixels, i
printed it
for check i use ENVI and use cursor/location option....
why values are different ? does ENVI_GET_ROI_DATA use some
interpolation algorithm?
Did you check to make sure you were handling your indices the right
way? ENVI routines like ENVI_GET_ROI_DATA will use zero-based
indices, while in the ENVI GUI (ie, the cursor location/value tool)
one-based indices are used.
yes, i know about it.
now, i faced with problem.
roi_ids=ENVI_GET_ROI_IDS(NS=ns,NL=nl,ROI_NAMES=roi_names,/SHORT_NAME)
in first runtime i have size of roi_names = 4, the same for roi_ids
second runtime size of roi_names = 8, the same with roi_ids.
why data is appended to roi_names and roi_ids ????- Hide quoted text -
- Show quoted text -
If your program includes a step where you are defining ROIs, then you
most likely ran the program twice in the same ENVI session without
cleaning up the ROIs created during the first run. You can check this
by loading the image you are working with to a display, then open the
ROI tool for that display. You'll likely see the same set of ROIs
listed twice. To get around this, one approach would be to make sure
that no ROIs are associated with your image prior to creating new
ones. You can put these lines at the beginning of your program, right
after you obtain the FID for the image you are working with:
roi_ids = envi_get_roi_ids(fid=fid)
envi_delete_rois, roi_ids
Any ROIs associated with the image will be deleted, so you can start
with a clean slate. As for the differences in retrieved data values,
keep in mind that data are returned in an array that has an array of
1D image coordinate addresses associated with it (returned through the
ADDR keyword to ENVI_GET_ROI_DATA). You should convert these 1D
coordinates to 2D if you want to check to make sure that the correct
data are being returned. To do this:
roi_ids = envi_get_roi_ids(fid=fid)
;as an example, retrieve data from first ROI in the list
roi_data = envi_get_roi_data(roi_ids[0], fid=fid, addr=addr)
;get number of samples in the image
envi_file_query, fid, ns=ns
;calculate 1-based coordinates for interactive evaluation in Cursor
Location/Value tool
roi_x_coords = (addr mod ns) + 1
roi_y_coords = (addr/ns) + 1
And no, ENVI_GET_ROI_DATA does not do any kind of interpolation. The
only data retrieval routine that does that is ENVI_GET_DATA--and only
when you specify X/Y scale factors that are not 1.0.