Main Content

dn2radiance

Convert digital number to radiance

Since R2020b

Description

newspcube = dn2radiance(spcube) converts the pixel values of the hyperspectral or multispectral data from digital number to radiance values. The function returns a new spectral object and the pixel values of the data are the top of atmosphere (TOA) radiances.

example

newspcube = dn2radiance(spcube,BlockSize=blocksize) specifies the block size for block processing of the spectral data. (since R2021a)

The function divides the input image into distinct blocks, processes each block, and then concatenates the processed output of each block to form the output matrix. Spectral images are multi-dimensional data sets that can be too large to fit in system memory in their entirety. This can cause the system to run out of memory while running the dn2radiance function. If you encounter such an issue, perform block processing by using this syntax.

For example, dn2radiance(spcube,BlockSize=[50 50]) divides the input image into non-overlapping blocks of size 50-by-50 and then computes the radiance values for pixels in each block.

Note

This function requires the Hyperspectral Imaging Library for Image Processing Toolbox™. You can install the Hyperspectral Imaging Library for Image Processing Toolbox from Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

The Hyperspectral Imaging Library for Image Processing Toolbox requires desktop MATLAB®, as MATLAB Online™ and MATLAB Mobile™ do not support the library.

Examples

collapse all

Read hyperspectral data into the workspace.

hcube = imhypercube("EO1H0440342002212110PY_cropped.hdr");

Determine the bad spectral band numbers using the BadBands parameter in the metadata.

bandNumber = find(~hcube.Metadata.BadBands);

Remove the bad spectral bands from the data cube.

hcube = removeBands(hcube,BandNumber=bandNumber);

Compute the radiance values using the dn2radiance function.

newhcube = dn2radiance(hcube);

Read and display a spectral band image in the input and the output radiance data.

inputBand = gather(hcube);
radianceBand = gather(newhcube);
band = 80;
figure
subplot(1,2,1)
imagesc(inputBand(:,:,band))
title("Input Band")
axis off
subplot(1,2,2)
imagesc(radianceBand(:,:,band))
title("Radiance Band")
axis off
colormap gray 

Figure contains 2 axes objects. Hidden axes object 1 with title Input Band contains an object of type image. Hidden axes object 2 with title Radiance Band contains an object of type image.

Download Landsat 8 multispectral data.

zipfile = "LC08_L1TP_113082_20211206_20211215_02_T1.zip";
landsat8Data_url = "https://ssd.mathworks.com/supportfiles/image/data/" + zipfile;
hyper.internal.downloadLandsatDataset(landsat8Data_url,zipfile)
filepath = fullfile("LC08_L1TP_113082_20211206_20211215_02_T1","LC08_L1TP_113082_20211206_20211215_02_T1_MTL.txt");

Read a multispectral image into the workspace, and resample it to a uniform resolution.

mcube = immulticube(filepath);
mcube = resampleBands(mcube,30);

Convert the digital numbers to radiance values.

newmcube = dn2radiance(mcube);

Visualize a band from the input and output multispectral data.

inputBand = gather(mcube);
radianceBand = gather(newmcube);
band = 5;
figure
subplot(1,2,1)
imagesc(inputBand(:,:,band))
title("Input Band")
axis off
subplot(1,2,2)
imagesc(radianceBand(:,:,band))
title("Radiance Band")
axis off
colormap gray 

Figure contains 2 axes objects. Hidden axes object 1 with title Input Band contains an object of type image. Hidden axes object 2 with title Radiance Band contains an object of type image.

Input Arguments

collapse all

Input spectral data, specified as a hypercube or multicube object. To convert the pixel values in digital numbers to radiance values, the Metadata property of the hypercube or multicube object must contain the Gain and Offset fields.

If spcube is a multicube object, all its spectral bands must have the same data resolution. If all spectral bands of the multicube object do not have the same resolution, resample the bands using the resampleBands function, or select bands with uniform resolution using the selectBands function.

Size of the data blocks, specified as a 2-element vector of positive integers. The elements of the vector correspond to the number of rows and columns in each block, respectively. The size of the data blocks must be less than the size of the input image. Dividing the spectral images into smaller blocks enables you process large data sets without running out of memory.

  • If the blocksize value is too small, the memory usage of the function reduces at the cost of increased execution time.

  • If the blocksize value is large or equal to the input image size, the execution time reduces at the cost of increased memory usage.

Example: BlockSize=[20 20] specifies the size of each data block as 20-by-20.

Output Arguments

collapse all

Output spectral data, returned as a hypercube or multicube object. The pixels values of the output data cube are radiances specifying the amount of radiation from the surface being imaged. The radiance values are computed from digital numbers by using the equation:

Radiance Lλ=(DN×Gain)+Bias

Gain and Bias are the gain and offset values for each spectral bands respectively. The Metadata property of the spectral object contains the gain and the offset values.

Version History

Introduced in R2020b

expand all