-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmnf.m
More file actions
47 lines (30 loc) · 1.33 KB
/
mnf.m
File metadata and controls
47 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function [reconst, A] = mnf(data, m1, m2, k)
% Finds the first k components of Minimum Noise Fraction transformation on
% 3D (e.g. hyperspectral) data, and uses them to reconstruct the data
%
% Reference:
% Lee, James B., A. Stephen Woodyatt, and Mark Berman. "Enhancement of
% high spectral resolution remote-sensing data by a noise-adjusted
% principal components transform." Geoscience and Remote Sensing, IEEE
% Transactions on 28.3 (1990): 295-304.
%
% Input: data -- A 2D array of data. The first dimension is of length
% m1*m2 and contains spatial data. The second dimension
% contains spectral data of length n.
% m1,m2 -- dimensions of the original spatial data
% k -- number of required components
%
% Output: reconst -- reconstructed data
% A -- n x k matrix for transforming data
% Estimate the noise
N = noise_estimate(data, m1, m2);
% Centre the data
means_by_wavenumber = sum(data)/(m1 * m2);
means_matrix = ones(m1 * m2, 1) * means_by_wavenumber;
data = data - means_matrix;
% Use this estimate to whiten the noise
data_whitened = whiten_noise(data, N);
% Get k principal components from data with whitened noise
[~, ~, A] = svds(data_whitened, k);
% Reconstitute original data using those k principal components
reconst = data * (A * A') + means_matrix;