ROI Data Retrival [message #94515] |
Sat, 17 June 2017 01:23  |
moxament
Messages: 26 Registered: April 2008
|
Junior Member |
|
|
Dear all,
I am trying to write a code in which an ENVI format image with multi-bands is opened and the associated ROI file is restored. I want to get the data of each class from the image. I have three classes and for each class I want to create an array with number of columns equal to the number of bands and number of lines equal to the number of selected pixels of the ROI (class). My code looks like:
;Open and read the all-band file
ENVI_OPEN_FILE, Inputbands, R_FID = FID, NO_REALIZE = 1
;Read the header of the data image file
ENVI_FILE_QUERY, fid, ns = ns, nl = nl, nb = nb
; Restore the pre saved regions of interest.
envi_restore_rois, InputROI
roi_ids = envi_get_roi_ids(fid=fid, roi_colors=roi_colors, roi_names=class_names)
Result = ENVI_GET_ROI_DATA(roi_ids, FID=FID)
However, when I run the code I get the following error:
% Expression must be a scalar or 1 element array in this context: <BYTE Array[3]>.
% Execution halted at: ENVI_ROI_ID_VALID 247
% ENVI_GET_ROI_DATA 908
% $MAIN$
Can you please help? Your efforts are appreciated!!
|
|
|
Re: ROI Data Retrival [message #94517 is a reply to message #94515] |
Mon, 19 June 2017 01:27   |
Markus Schmassmann
Messages: 129 Registered: April 2016
|
Senior Member |
|
|
On 06/17/2017 10:23 AM, moxament@gmail.com wrote:
> I am trying to write a code in which an ENVI format image with multi-bands is opened and the associated ROI file is restored. I want to get the data of each class from the image. I have three classes and for each class I want to create an array with number of columns equal to the number of bands and number of lines equal to the number of selected pixels of the ROI (class). My code looks like:
>
> ;Open and read the all-band file
> ENVI_OPEN_FILE, Inputbands, R_FID = FID, NO_REALIZE = 1
>
> ;Read the header of the data image file
> ENVI_FILE_QUERY, fid, ns = ns, nl = nl, nb = nb
>
> ; Restore the pre saved regions of interest.
> envi_restore_rois, InputROI
> roi_ids = envi_get_roi_ids(fid=fid, roi_colors=roi_colors, roi_names=class_names)
>
> Result = ENVI_GET_ROI_DATA(roi_ids, FID=FID)
>
> However, when I run the code I get the following error:
>
> % Expression must be a scalar or 1 element array in this context: <BYTE Array[3]>.
> % Execution halted at: ENVI_ROI_ID_VALID 247
> % ENVI_GET_ROI_DATA 908
> % $MAIN$
>
> Can you please help? Your efforts are appreciated!!
As an educated guess, I'd say roi_ids is an array, but must be a
scalar or 1 element array. So you probably have to loop. --Markus
|
|
|
Re: ROI Data Retrival [message #94518 is a reply to message #94517] |
Mon, 19 June 2017 11:52  |
moxament
Messages: 26 Registered: April 2008
|
Junior Member |
|
|
On Monday, 19 June 2017 04:27:42 UTC-4, Markus Schmassmann wrote:
> On 06/17/2017 10:23 AM, moxament@gmail.com wrote:
>> I am trying to write a code in which an ENVI format image with multi-bands is opened and the associated ROI file is restored. I want to get the data of each class from the image. I have three classes and for each class I want to create an array with number of columns equal to the number of bands and number of lines equal to the number of selected pixels of the ROI (class). My code looks like:
>>
>> ;Open and read the all-band file
>> ENVI_OPEN_FILE, Inputbands, R_FID = FID, NO_REALIZE = 1
>>
>> ;Read the header of the data image file
>> ENVI_FILE_QUERY, fid, ns = ns, nl = nl, nb = nb
>>
>> ; Restore the pre saved regions of interest.
>> envi_restore_rois, InputROI
>> roi_ids = envi_get_roi_ids(fid=fid, roi_colors=roi_colors, roi_names=class_names)
>>
>> Result = ENVI_GET_ROI_DATA(roi_ids, FID=FID)
>>
>> However, when I run the code I get the following error:
>>
>> % Expression must be a scalar or 1 element array in this context: <BYTE Array[3]>.
>> % Execution halted at: ENVI_ROI_ID_VALID 247
>> % ENVI_GET_ROI_DATA 908
>> % $MAIN$
>>
>> Can you please help? Your efforts are appreciated!!
> As an educated guess, I'd say roi_ids is an array, but must be a
> scalar or 1 element array. So you probably have to loop. --Markus
Hi Markus,
Thank you for your response. Yes, roi_ids is an array and I tried to run envi_get_roi_ids on one element (roi_ids[0] but still getting error). Any other suggestion would be appreciated.
Mohammed
|
|
|