-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbasic_test.m
More file actions
executable file
·44 lines (36 loc) · 1008 Bytes
/
basic_test.m
File metadata and controls
executable file
·44 lines (36 loc) · 1008 Bytes
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
39
40
41
42
43
44
% Basic example of how to use the NMF_ML algorithm for image unmixing.
%
% Thomas Pengo, June 18th 2013
%
% Requires DipImage (www.diplib.org). Uncomment and change the following
% two lines accordingly after installing.
%
% addpath C:\Program' Files'\DIPimage' 2.4.1'\
% dipstart
%
% Create F1 and F2
dsk = rr<5;
m = dsk | resample(1*dsk,1,[-20 -20])>0;
% Generate two 'concentration' images
F1 = noise(1000*dsk+10,'poisson',1);
F2 = noise(resample(1000*dsk+10,1,[-20 -20]),'poisson',1);
im = dip_image({F1 F2});
joinchannels('RGB',im)
% Mixing matrix
A = [1 0;.5 1];
% 'Concentration' matrix, ground truth
H = [double(F1(m));double(F2(m))];
% Mix signals
Y = A*H;
% Mixed images
F1_ = newim; F1_(m)=Y(1,:);
F2_ = newim; F2_(m)=Y(2,:);
im_ = dip_image({F1_ F2_});
joinchannels('RGB',im_)
% Unmix images
[A H xts] = NMF_ML(Y,m);
% Unmixed images
F1e = newim; F1e(m)=H(1,:);
F2e = newim; F2e(m)=H(2,:);
ime = dip_image({F1e F2e});
joinchannels('RGB',ime)