%% Assign New Reflectance Values to Hyperspectral Data
% Read hyperspectral data from an ENVI format file.

hcube = hypercube('paviaU.dat');

% Normalize the reflectance values to the range [0, 1].

data = rescale(hcube.DataCube);

% Assign the normalized reflectance values to the data cube.

newhcube = assignData(hcube,':',':',':',data);

% Specify the row and column indices of a region of interest (ROI). Assign all indices within the ROI a value of zero.

row = 180:220;
column = 125:160;
newhcube = assignData(newhcube,row,column,':',0);

% Display the original and the modified versions of a spectral band.

fig = figure('Position',[0 0 800 500]);
axes1 = axes('Parent',fig,'Position',[0.06 0.05 0.45 0.8]);
imagesc(hcube.DataCube(:,:,10),'Parent',axes1);
title('Original Data')
colorbar
axis off
axes2 = axes('Parent',fig,'Position',[0.55 0.05 0.45 0.8]);
imagesc(newhcube.DataCube(:,:,10),'Parent',axes2);
title('Modified Data')
colorbar
axis off
colormap gray  

% Copyright 2020 The MathWorks, Inc.