Main Content

subtractDarkPixel

Subtract dark pixel value from hyperspectral data cube

    Description

    example

    correctedData = subtractDarkPixel(inputData) subtracts the minimum pixel value of each band from all pixels in that band of the hyperspectral data, inputData. The pixels with minimum intensity values are the dark pixels of the hyperspectral data.

    correctedData = subtractDarkPixel(inputData,darkPixels) subtracts the specified value, 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 0.

    correctedData = subtractDarkPixel(___,'BlockSize',blocksize) specifies the block size for block processing of the hyperspectral data cube by using the name-value pair argument '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 the subtractDarkPixel function. If you encounter such an issue, perform block processing by using this syntax.

    For example, subtractDarkPixel(inputData,darkPixels,'BlockSize',[50 50]) divides the input image into non-overlapping blocks of size 50-by-50 and then performs dark pixel subtraction on each block.

    Note

    To perform block processing by specifying the 'BlockSize' name-value pair argument, you must have MATLAB R2021a or a later release.

    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

    collapse all

    Read hyperspectral data into the workspace.

    hcube = hypercube('paviaU');

    Subtract the minimum pixel value of each band from all pixels in that band.

    hcubeCorrected = subtractDarkPixel(hcube);

    Input Arguments

    collapse all

    Input hyperspectral data, specified as one of the following.

    • hypercube object. The DataCube property of the hypercube object stores the hyperspectral data cube.

    • M-by-N-by-C numeric array — M and N are the number of rows and columns in each band of hyperspectral data. C is the number of spectral bands in the hyperspectral dataset.

    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.

    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.

    • 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

    Corrected hyperspectral data, returned as a hypercube object or M-by-N-by-C numeric array with data cube dimensions equal to those of the input data inputData.

    References

    [1] 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