Subtract dark pixel value from hyperspectral data cube
subtracts the specified value,
correctedData = subtractDarkPixel(
darkPixels, from all pixels in each
hyperspectral band. You can specify a single value to subtract across all bands of the data
cube or a separate value for each band. After subtraction, the function sets all negative
pixel values to
specifies the block size for block processing of the hyperspectral data cube by using the
name-value pair argument
correctedData = subtractDarkPixel(___,'BlockSize',
'BlockSize'. You can specify the
'BlockSize' name-value pair argument in addition to the input arguments
in the previous syntaxes.
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. Hyperspectral 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
subtractDarkPixel function. If you encounter such an issue, perform block
processing by using this syntax.
50]) divides the input image into non-overlapping blocks of size 50-by-50 and
then performs dark pixel subtraction on each block.
To perform block processing by specifying the
pair argument, you must have MATLAB® R2021a or a
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.
The Image Processing Toolbox Hyperspectral Imaging Library requires desktop MATLAB, as MATLAB Online™ or MATLAB Mobile™ do not support the library.
Subtract Band Minimum Pixel Values from Hyperspectral Data
Read hyperspectral data into the workspace.
hcube = hypercube("paviaU");
Subtract a dark pixel value from all pixels of all bands.
hcubeCorrected = subtractDarkPixel(hcube,500);
Display the RGB images of the original hyperspectral data and the hyperspectral data after correction.
colorImg = colorize(hcube,Method="rgb"); colorImgCorrected = colorize(hcubeCorrected,Method="rgb"); figure imagesc([colorImg colorImgCorrected])
darkPixels — Value to subtract from pixels of each band
numeric scalar | C-element numeric vector
Value to subtract from the pixels of each band, specified as a numeric scalar or a C-element numeric vector. C is the number of bands in the hyperspectral dataset. If you specify a scalar, the function subtracts that value from the pixels of all bands in the dataset.
blocksize — Size of data blocks
2-element vector of positive integers
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 hyperspectral images into smaller blocks enables you process large data sets without running out of memory.
blocksizevalue is too small, the memory usage of the function reduces at the cost of increased execution time.
blocksizevalue is large or equal to the input image size, the execution time reduces at the cost of increased memory usage.
'BlockSize',[20 20] specifies the size of each data block
 Souri, A. H. and M. A. Sharifi. "Evaluation of Scene-Based Empirical Approaches for Atmospheric Correction of Hyperspectral Imagery." Paper presented at the 33rd Asian Conference on Remote Sensing, Pattaya, Thailand, November 2012.
Introduced in R2020b