assignData
Assign new data to hyperspectral data cube
Description
assigns the specified newhcube
= assignData(hcube
,row
,column
,band
,data
)data
to a hyperspectral data cube. The function
reads the data cube stored in the hypercube
object
hcube
, assigns the new data to the spectral bands
band
at the locations specified by row
and
column
, and returns a new hypercube
object.
Note
This function requires the Image Processing Toolbox™ Hyperspectral Imaging Library. You can install the Image Processing Toolbox Hyperspectral Imaging Library from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.
Examples
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
Input Arguments
hcube
— Input hyperspectral data
hypercube
object
Input hyperspectral data, specified as a hypercube
object. The DataCube
property of the hypercube
object contains the hyperspectral data cube.
row
— Row indices of data cube
':'
| positive integer | vector of positive integers
Row indices of the data cube, specified as ':'
, a positive
integer, or a vector of positive integers.
To select all the rows in the data cube, use
':'
.To select a particular row or rows, specify the row index as a positive integer or vector of positive integers respectively. If the data cube is of size M-by-N-by-C, the specified row index values must all be less than or equal to M. To specify a range of row indices, or indices at a regular interval, use the
colon
operator. For example,row = 1:10
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| char
| string
column
— Column indices of data cube
':'
| positive integer | vector of positive integers
Column indices of the data cube, specified as ':'
, a positive
integer, or a vector of positive integers.
To select all the columns in the data cube, use
':'
.To select a particular column or columns, specify the column index as a positive integer or vector of positive integers respectively. If the data cube is of size M-by-N-by-C, the specified column index values must all be less than or equal to N. To specify a range of column indices, or indices at a regular interval, use the
colon
operator. For example,column = 1:10
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| char
| string
band
— Spectral band numbers
':'
| positive integer | vector of positive integers
Spectral band numbers, specified as ':'
, a positive integer or a
vector of positive integers.
To select all the bands in the data cube, use
':'
.To select a particular band or bands, specify the band number as a positive integer or vector of positive integers respectively. If the data cube is of size M-by-N-by-C, the specified band number values must all be less than or equal to C. To specify a range of band numbers or numbers at a regular interval, use the
colon
operator. For example,band = 1:10
.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| char
| string
data
— Values to assign
scalar | vector | matrix | 3-D array
Values to assign, specified as a scalar, vector, matrix, or 3-D array depending on
the values of the row
, column
, and
band
inputs.
If row is | If column is | If band is | data must be |
---|---|---|---|
scalar | scalar | scalar | scalar |
M- element vector | scalar | scalar | M- element row vector or M-by-1 matrix or M-by-1-by-1 array |
scalar | N-element vector | scalar | N- element column vector or 1-by-N matrix or 1-by-N-by-1 array |
scalar | scalar | C-element vector | 1-by-1-by-C array |
M- element vector | N-element vector | scalar | M-by-N matrix or M-by-N-by-1 array |
M- element vector | N-element vector | C-element vector | M-by-N-by-C array |
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
Output Arguments
newhcube
— Output hyperspectral data
hypercube
object
Output hyperspectral data, returned as a hypercube
object.
Version History
Introduced in R2020a
See Also
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)