Clear Filters
Clear Filters

How do I read multiband envi generated image file into matlab?

3 views (last 30 days)
I am reading the multiband envi generated image file into matlab by using following matlab code;
img_path = 'C:\Image_Data\'
d = uigetdir(pwd, 'Select a folder');
imgfiles = dir(fullfile(d, '*.img'));
for m = 1:length(imgfiles)
img_file = imgfiles(m);
disp(img_file.name);
img = imread(img_file.name);
red = img(:,:,4); % red band
rededge1 = img(:,:,5); % rededge1 band
rededge2 = img(:,:,6); % rededge2 band
rededge3 = img(:,:,7); % rededge3 band
nir = img(:,:,8); % near infrared band
This is giving the following error
>> ds_indices_caf
img_path =
'C:\Image_Data\'
20240309_SAMPLE_DATA.img
Error using imread>get_full_filename
File "20240309_SAMPLE_DATA.img" does not exist.
Error in imread (line 372)
fullname = get_full_filename(filename);
Error in ds_indices_caf (line 17)
img = imread(img_file.name);
>>
I am attaching the envi image file and request to kindly help me out to read the data from the image file.
Deva
  1 Comment
Devendra
Devendra on 26 Mar 2024
I have kept matlab code and input data in same directory. Now following errors are coming;
>> ds_indices_caf
img_path = 'C:\Data\'
20240309_SAMPLE_DATA.img
Error using imread>get_format_info (line 554)
Unable to determine the file format.
Error in imread (line 395)
fmt_s = get_format_info(fullname);
Error in ds_indices_caf (line 17)
img = imread(img_file.name);
I would appreciate any help to fix it.
Deva

Sign in to comment.

Answers (0)

Products


Release

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!