-
Notifications
You must be signed in to change notification settings - Fork 2
/
confMapDistribution.m
87 lines (66 loc) · 2.04 KB
/
confMapDistribution.m
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
% Compute confidence map
% Input:
% data: RF ultrasound data (one scanline per column)
% mode: 'RF' or 'B' mode data
% alpha, beta, gamma: See Medical Image Analysis reference
% Output:
% map: Confidence map for data
function [ map ] = confMapDistribution( data, alpha, beta, gamma, sim_measure)
disp('Preparing confidence estimation...');
% Default parameter settings
if nargin < 4
alpha = 2.0;
beta = 90;
gamma = 0.05;
end
%if(nargin < 5)
% mode = 'B';
%end
%data = double(data);
%data = (data - min(data(:))) ./ ((max(data(:))-min(data(:)))+eps);
%if(strcmp(mode,'RF'))
% data = abs(hilbert(data));
%end
% 1, 2, 4, 40
% uncomment
% neck
%gammaMap = GenerateGammaImage(data,2,8,4,40);
%
gammaMap = GenerateGammaImage(data,2,6,10,40);
%save('gammaMap.mat','gammaMap');
%load('gammaMap.mat');
% Seeds and labels (boundary conditions)
seeds = [];
labels = [];
sc = 1:size(gammaMap(:,:,1),2); %All elements
%SOURCE ELEMENTS - 1st matrix row
sr_up = ones(1,length(sc));
seed = sub2ind(size(gammaMap(:,:,1)),sr_up,sc);
seed = unique(seed);
seeds = [seeds seed];
% Label 1
label = zeros(1,length(seed));
label = label + 1;
labels = [labels label];
%SINK ELEMENTS - last image row
sr_down = ones(1,length(sc));
sr_down = sr_down * size(gammaMap(:,:,1),1);
seed = sub2ind(size(gammaMap(:,:,1)),sr_down,sc);
seed = unique(seed);
seeds = [seeds seed];
%Label 2
label = zeros(1,length(seed));
label = label + 2;
labels = [labels label];
% Attenuation with Beer-Lambert
W = attenuationWeighting(data,alpha);
W = imresize(W, size(gammaMap(:,:,1)));
disp('Solving confidence estimation problem, please wait...');
% Apply weighting directly to image
% Same as applying it individually during the formation of the Laplacian
%data = data .* W;
% Find condidence values
map = confidenceEstimationDistribution( gammaMap, W, seeds, labels, beta, gamma, sim_measure);
% Only keep probabilities for virtual source notes.
map = map(:,:,1);
end