Main Content

detectTarget

Detect target in hyperspectral image

Since R2024a

    Description

    You can use the detectTarget function for applications such as airplane detection, mineral identification, and so on. The detectTarget function supports various target detection techniques. Target detection techniques can be more useful than spectral matching techniques if the spectral differences between the target and other regions are very subtle, or if the background clutter in the image is complex or heterogeneous.

    example

    score = detectTarget(hCube,target,method) detects the target target in the hyperspectral image hCube using the method method and returns the target detection score score.

    score = detectTarget(hCube,target,method,numEndmember=numEndmembers) specifies the number of endmembers to unmix for the AMSD and OSP methods.

    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.

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

    Examples

    collapse all

    Load a hyperspectral image into the workspace.

    hCube = hypercube("paviaU.dat");

    Colorize the hyperspectral image to get an RGB image.

    rgbImg = colorize(hCube,Method="rgb",ContrastStretching=true);

    Normalize the hyperspectral image by removing its continuum.

    continuumRemovedCube = removeContinuum(hCube);

    To detect the roof in the hyperspectral image, specify one pixel in the roof region and extract its spectral signature to use as your target.

    target = squeeze(continuumRemovedCube.DataCube(170,133,:));

    Compute the target detection scores of the hyperspectral image pixels with respect to the selected target.

    score = detectTarget(continuumRemovedCube,target,"MF");

    Visualize the histogram of the score image of the target detection. Observe that the histogram has two peaks. Specify a threshold of 0.5, between the two histogram peaks, for classifying whether each pixel contains the target. A true value, representing a pixel with a target detection score greater than 0.5 in the target detection image, indicates that the target is present in that pixel, and a false value indicates that the target is not present.

    figure
    histogram(score)

    threshold = 0.5;
    targetImg = score > threshold;

    Load the ground truth target detection image.

    load("paviauRoofingGT.mat")
    gtImg = paviauRoofingGT;

    Visualize the RGB image of the hyperspectral image, the ground truth target detection image, and the computed target detection image.

    figure
    tiledlayout(1,3)
    nexttile
    imagesc(rgbImg)
    title("RGB Image")
    nexttile
    imagesc(gtImg)
    title("Ground Truth")
    nexttile
    imagesc(targetImg)
    title("Detected Target")

    Compute the Dice similarity between the ground truth and computed target detection images.

    similarity = dice(targetImg,gtImg)
    similarity = 0.9368
    

    Input Arguments

    collapse all

    Hyperspectral data cube, specified as a hypercube object or a 3-D numeric array.

    Spectral signature of the target, specified as a C-element numeric vector. C is the number of bands in the input hyperspectral data cube.

    You can select the spectral signature of the target in these ways.

    • Specify the spectral signature of a single pixel in the hyperspectral data cube as the target. In this case, the detectTarget function returns a high target detection score at the chosen pixel because it is an exact match for itself, but the target detection score at other pixels can be significantly lower because they might not be exact matches.

    • Specify the average spectral signature of a group of pixels in a region of interest (ROI) in the hyperspectral data cube as the target. In this case, the detectTarget function returns a high target detection score for pixels whose spectral signatures are similar to the average spectral signature of the ROI.

    • Specify a spectral signature from a different data set or a spectral library as the target. You might have to resample the target spectral signature and remove the continuum of the target spectrum and the pixel spectra to make the target comparable with the input hyperspectral data cube. An external target spectral signature might not be an exact match for the target in the image, but you can use it as a representative spectral signature for the target. By comparing the external target spectral signature with the spectral signatures in the data cube, you can still detect the presence of similar targets. In this case, the detectTarget function returns a high target detection score for pixels with spectral signatures similar to the spectral signature of the external target.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Method of target detection, specified as one of these options.

    • "CEM" — Constrained energy minimization (CEM)

    • "ACE" — Adaptive cosine estimator (ACE)

    • "SignedACE" — Signed adaptive cosine estimator (Signed ACE)

    • "MF" — Matched filter (MF)

    • "GLRT" — Generalized likelihood ratio test (GLRT)

    • "AMSD" — Adaptive matched subspace detector (AMSD)

    • "OSP" — Orthogonal subspace projection (OSP)

    For more information about these methods, see Spectral Matching and Target Detection Techniques.

    Data Types: char | string

    Number of endmembers to unmix, specified as a positive integer. This argument is applicable only for the AMSD and OSP methods. You can find the number of endmembers in the hyperspectral data cube by using the countEndmembersHFC function.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Output Arguments

    collapse all

    Target detection score, returned as an M-by-N numeric matrix. M and N are the number of rows and columns in the input hyperspectral data cube, respectively. A higher score at a particular pixel location indicates a higher probability that the pixel location contains the target.

    Data Types: double

    References

    [1] Nasrabadi, Nasser M. “Hyperspectral Target Detection : An Overview of Current and Future Challenges.” IEEE Signal Processing Magazine 31, no. 1 (January 2014): 34–44. https://doi.org/10.1109/MSP.2013.2278992.

    [2] Du, Qian, Hsuan Ren, and Chein-I Chang. “A Comparative Study for Orthogonal Subspace Projection and Constrained Energy Minimization.” IEEE Transactions on Geoscience and Remote Sensing 41, no. 6 (June 2003): 1525–29. https://doi.org/10.1109/TGRS.2003.813704.

    [3] Jin, Xiaoying, Scott Paswaters, and Harold Cline. “A Comparative Study of Target Detection Algorithms for Hyperspectral Imagery.” In Proceedings of the SPIE 7334, Algorithms and Technologies for Multispectral, Hyperspectral, and Ultraspectral Imagery XV, 73341W (April 2009): 682–93. https://doi.org/10.1117/12.818790.

    [4] Ayoub, T.F., and A.R. Haimovich. “Modified GLRT Signal Detection Algorithm.” IEEE Transactions on Aerospace and Electronic Systems 36, no. 3 (July 2000): 810–18. https://doi.org/10.1109/7.869498.

    [5] Broadwater, J., R. Meth, and R. Chellappa. “A Hybrid Algorithm for Subpixel Detection in Hyperspectral Imagery.” In 2004 IEEE International Geoscience and Remote Sensing Symposium, vol. 3 (September 2004): 1601–4. https://doi.org/10.1109/IGARSS.2004.1370633.

    Version History

    Introduced in R2024a