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
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
%% Build far field covariance matrix

% Build the target area
boxTargetArea = boxArea( ...
    1 ,       ... wavelength
    10,       ... MFP (O.D. = 2)
    [-10,10], ... z
    [-10,10]  ... x
);

% views config, define by angles
viewsDirections = 0:1:359;
views = farFieldSource(deg2rad(viewsDirections),0);

% lights config, lighting in some directions
lightsDirections = [0, 1, 4, 20];
lights = farFieldSource(deg2rad(lightsDirections),0);

% scatter config
% load measured amplitude (generated by mu-diff far field)
load('scatteringAmplitude.mat', 'theta', 'farField')
scatter = tabulatedAmplitudeScatter( ...
    theta,   ... diirections
    farField ... measured amplitude
);

% Show the scattering function
figure
polarplot(theta, abs(farField).^2);
title('Scattering function of single particle')

%% Sovle scmc with CBS
tic
CBSres = scmc(boxTargetArea,views,lights,scatter,1e3,'CBS',true,'parforIters',12);
toc

%% Sovle scmc without CBS
tic
NCBSres = scmc(boxTargetArea,views,lights,scatter,1e3,'CBS',false,'parforIters',12);
toc

%% Compare cov matrix
f = figure;
f.Position = [0,0,1200,700];
maxval = max(abs([CBSres.C(:);NCBSres.C(:)]));

subplot(2,4,1);
imagesc(viewsDirections,viewsDirections,abs(CBSres.C(:,:,1,1)),[0,maxval]);
xlabel('view[deg]');
ylabel({'CBS','view[deg]'});
title(['(',num2str(lightsDirections(1)),'\circ,',num2str(lightsDirections(1)),'\circ)']);

subplot(2,4,2);
imagesc(viewsDirections,viewsDirections,abs(CBSres.C(:,:,1,2)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');
title(['(',num2str(lightsDirections(1)),'\circ,',num2str(lightsDirections(2)),'\circ)']);

subplot(2,4,3);
imagesc(viewsDirections,viewsDirections,abs(CBSres.C(:,:,1,3)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');
title(['(',num2str(lightsDirections(1)),'\circ,',num2str(lightsDirections(3)),'\circ)']);

subplot(2,4,4);
imagesc(viewsDirections,viewsDirections,abs(CBSres.C(:,:,1,4)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');
title(['(',num2str(lightsDirections(1)),'\circ,',num2str(lightsDirections(4)),'\circ)']);

subplot(2,4,5);
imagesc(viewsDirections,viewsDirections,abs(NCBSres.C(:,:,1,1)),[0,maxval]);
xlabel('view[deg]');
ylabel({'Without CBS','view[deg]'});

subplot(2,4,6);
imagesc(viewsDirections,viewsDirections,abs(NCBSres.C(:,:,1,2)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');

subplot(2,4,7);
imagesc(viewsDirections,viewsDirections,abs(NCBSres.C(:,:,1,3)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');

subplot(2,4,8);
imagesc(viewsDirections,viewsDirections,abs(NCBSres.C(:,:,1,4)),[0,maxval]);
xlabel('view[deg]');
ylabel('view[deg]');

%% Compare diagonals
figure

hold on
plot(viewsDirections,diag(abs(CBSres.C(:,:,1,1))), 'lineWidth', 2);
plot(viewsDirections,diag(abs(NCBSres.C(:,:,1,1))), 'lineWidth', 2);

xlabel('view[deg]');
ylabel('intensity');

legend('With CBS','Without CBS')