Main Content

flatField

Apply flat field correction to spectral data

Since R2020b

    Description

    correctedData = flatField(inputData,roi) applies flat field correction to the hyperspectral or multispectral data, inputData, using the flat field mean spectrum calculated in the specified region of interest (ROI) of the data. A valid ROI has these characteristics:

    • Topographically flat

    • Spectrally flat (uniform spectral response)

    • Strong signal source to reduce the impact of random noise

    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.

    example

    Examples

    collapse all

    Read hyperspectral data into the workspace.

    hcube = imhypercube("paviaU");

    Display the contrast-stretched RGB color image of the hyperspectral data.

    coloredImg = colorize(hcube,Method="rgb",ContrastStretching=true);
    figure
    imshow(coloredImg)

    Figure contains an axes object. The hidden axes object contains an object of type image.

    Specify the ROI from which to calculate the flat field mean spectrum.

    roi = [1 1 10 10];

    Apply the flat field correction to the hyperspectral data.

    hcube_flatfield = flatField(hcube,roi); 

    Read the spectral signature of vegetation from the ECOSTRESS spectral library.

    filename = "vegetation.tree.tsuga.canadensis.vswir.tsca-1-47.ucsb.asd.spectrum.txt";
    libData = readEcostressSig(filename);

    Compute the distance scores of the spectrum of the original hyperspectral data pixels with respect to the reference spectrum.

    score = spectralMatch(libData,hcube);

    Compute the distance scores of the spectrum of the flat field corrected hyperspectral data pixels with respect to the reference spectrum.

    score_flatfield = spectralMatch(libData,hcube_flatfield);

    Display the distance scores of the original and the flat field corrected hyperspectral data. The pixels with low distance scores are stronger matches to the reference spectrum, and are more likely to belong to the vegetation region. Observe that the distance scores after flat field correction can differentiate between light vegetation cover and dense vegetation cover.

    figure
    imagesc([score score_flatfield])
    colorbar
    title("Original Distance Score | Distance Score after Flat Field Correction")

    Figure contains an axes object. The axes object with title Original Distance Score | Distance Score after Flat Field Correction contains an object of type image.

    Input Arguments

    collapse all

    Input spectral data, specified as one of these options:

    • hypercube object.

    • multicube object.

    • M-by-N-by-C numeric array — M and N are the number of rows and columns of pixels in the spectral data, respectively. C is the number of spectral bands.

    The input pixel values can be digital numbers, TOA radiance values, or TOA reflectance values. To convert a spectral object containing digital numbers to a spectral object containing TOA radiance or TOA reflectance data, use the dn2radiance or dn2reflectance function, respectively.

    If inputData 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.

    ROI for the calculation of the flat field mean spectrum, specified as a 4-element vector of positive integers of the form [xmin ymin width height]. The vector defines a rectangular ROI within the spectral data. xmin and ymin are the xy-coordinates of the upper-left corner of the ROI. width and height are the width and height, respectively, of the ROI, in pixels

    Output Arguments

    collapse all

    Corrected spectral data, returned as a hypercube or multicube object or M-by-N-by-C numeric array consistent with the input data, inputData. If the input data in inputData is of data type double, then the corrected data is also of data type double. Otherwise, the corrected data is of data type single.

    References

    [1] Roberts, D. A., Y. Yamaguchi, and R. J. P. Lyon. "Comparison of Various Techniques for Calibration of AIS Data." In Proceedings of the Second Airborne Imaging Spectrometer Data Analysis Workshop, ed. Gregg Vane and Alexander F. H. Goetz, 21 -30. Pasadena: Jet Propulsion Laboratory, 1986.

    Version History

    Introduced in R2020b

    expand all