def ace_local_detector(hsi_img, tgt_sig, mask = None, guard_win = 2, bg_win = 4, beta = 0):
	"""
	Adaptive Cosine/Coherence Estimator with RX style local background estimation

	Inputs:
		hsi_image - n_row x n_col x n_band hyperspectral image
		tgt_sig - target signature (n_band x 1 - column vector)
		mask - binary image limiting detector operation to pixels where mask is true
	           if not present or empty, no mask restrictions are used
		guard_win - guard window radius (square,symmetric about pixel of interest)
		bg_win - background window radius
		beta - scalar value used to diagonal load covariance

	Outputs:
		out - detector image

	10/25/2012 - Taylor C. Glenn
	6/2/2018 - Edited by Alina Zare
	10/2018 - Python Implementation by Yutai Zhou
	"""
	n_row, n_col, n_band = hsi_img.shape
	mask = np.ones([n_row, n_col]) if mask is None else mask
	reg = beta * np.eye(n_band)

	out, kwargsout = rx_det(ace_local_helper, hsi_img, tgt_sig, mask = mask, guard_win = guard_win, bg_win = bg_win, reg = reg)
	return out, kwargsout
def smf_local_detector(hsi_img, tgt_sig, mask=None, guard_win=2, bg_win=4):
    """
	Spectral Matched Filter with RX style local background estimation

	Inputs:
	 hsi_image - n_row x n_col x n_band hyperspectral image
	 tgt_sig - target signature (n_band x 1 - column vector)
	 mask - binary image limiting detector operation to pixels where mask is true
	        if not present or empty, no mask restrictions are used
	 guard_win - guard window radius (square,symmetric about pixel of interest)
	 bg_win - background window radius

	Outputs:
	 out - detector image

	10/25/2012 - Taylor C. Glenn
	10/2018 - Python Implementation by Yutai Zhou
	"""
    out, kwargsout = rx_det(smf_local_helper,
                            hsi_img,
                            tgt_sig,
                            mask=mask,
                            guard_win=guard_win,
                            bg_win=bg_win)
    return out
Exemple #3
0
def hsd_local_detector(hsi_img,
                       tgt_sig,
                       ems,
                       mask=None,
                       guard_win=2,
                       bg_win=4,
                       beta=0):
    """
	Hybrid Subpixel Detector with RX style local background estimation

	Inputs:
	 hsi_image - n_row x n_col x n_band hyperspectral image
	 tgt_sig - target signature (n_band x 1 - column vector)
	 mask - binary image limiting detector operation to pixels where mask is true
	        if not present or empty, no mask restrictions are used
	 guard_win - guard window radius (square,symmetric about pixel of interest)
	 bg_win - background window radius
	 beta - scalar value used to diagonal load covariance

	Outputs:
	 out - detector image

	1/25/2013 - Taylor C. Glenn
	6/3/2018 - Edited by Alina Zare
	12/2018 - Python Implementation by Yutai Zhou
	"""
    if tgt_sig.ndim == 1:
        tgt_sig = tgt_sig[:, np.newaxis]

    n_row, n_col, n_band = hsi_img.shape
    hsi_data = hsi_img.reshape((n_row * n_col, n_band), order='F').T

    reg = beta * np.eye(n_band)

    # unmix data with only background endmembers
    P = unmix(hsi_data, ems)

    # unmix data with target signature as well
    targ_P = unmix(hsi_data, np.hstack((tgt_sig, ems)))

    out, kwargsout = rx_det(hsd_local_helper,
                            hsi_img,
                            tgt_sig,
                            mask,
                            guard_win,
                            bg_win,
                            ems=ems,
                            reg=reg,
                            P=P,
                            targ_P=targ_P)
    return out