示例#1
0
 def test_mf_target_no_bg_eq_one(self):
     '''Matched Filter response of target should be one.'''
     from spectral.algorithms.detectors import matched_filter
     (i, j) = self.target_ij
     target = self.data[i, j]
     mf = matched_filter(self.data, target)
     np.testing.assert_approx_equal(mf[i, j], 1)
示例#2
0
 def test_mf_target_no_bg_eq_one(self):
     '''Matched Filter response of target should be one.'''
     from spectral.algorithms.detectors import matched_filter
     (i, j) = self.target_ij
     target = self.data[i, j]
     mf = matched_filter(self.data, target)
     np.testing.assert_approx_equal(mf[i, j], 1)
示例#3
0
                                             mask=None,
                                             index=None)
            print("Calculating stats of matchFilter...")
            '''
            Matched Filter for processing hyperspectral data
            H0 background distribution -> get it from the most of the images so as to 
            have a good background distribution
            H1 target distribution -> get it from the multiple image with the source information.
        
            aplha(x)=\frac{(\mu_t-\mu_b)^T\Sigma^{-1}(x-\mu_b)}{(\mu_t-\mu_b)^T\Sigma^{-1}(\mu_t-\mu_b)}
            OR
            aplha(x) = a_hat = (transpose(x-u) . inv_cov . (t-u) / (transpose(t-u) . inv_cov . (t-u))
            '''
            print("b_img_data", b_img_data[:,columns:col_range,:].shape, "target_mean : ", \
                    target_mean[start_pos:start_pos+bands_in_set].shape)
            alpha = np.concatenate((alpha, matched_filter(b_img_data[:,columns:col_range,:], \
                    target_mean[start_pos:start_pos+bands_in_set], b_mean_cov_obj)), axis=1)
            print("Shape of Alpha : ", alpha.shape)
        b_img_data = None
        del b_img_data
        bands_set_end = start_pos + bands_in_set
        processed_file = f'{mf_output_folder}/{sname}_{start_pos}_{end_pos}.npy'
        print("Saving the alpha output", processed_file)
        np.save(processed_file, alpha)

        start_pos += bands_in_set
        reset_pos += bands_in_set
        if (start_pos > channel): break
        if ((reset_pos % bands_in_set) == 0):
            start_pos = start_pos - overlap
            reset_pos = 0