1 % An example showing the whole process of learning and inferring
2 % Boundary 1 - working, but highly incomplete
6 FEATURE_EXTRACTION_METHOD = 2;
8 disp('Reading the data...');
9 read_data; % has to be configured first - see the code
11 % Set the range of potential boundary height values
13 max_height = size(Visuals{1}, 1);
15 disp('Extracting features...');
16 Features = cell(size(Visuals));
17 for i=1:length(Features)
18 Features{i} = extract_features(Visuals{i}, FEATURE_EXTRACTION_METHOD);
21 disp('Generating the hashtable for all possible feature vectors... (this may take a while)');
22 X_ht = get_all_possible_x(FEATURE_EXTRACTION_METHOD, min_height:max_height);
25 disp('Computing model parameters...');
26 [s, S, X] = get_probabilities(Features, Boundary1, X_ht, min_height, max_height, FEATURE_EXTRACTION_METHOD, 'gaussian', 1);
30 disp('Extracting features for a sample image...');
31 im = imread('/home/hynek/Media/Texty/Skola/GMM/OCT/Lernstichprobe/0183_B_01_05_Ru_6_SR830-i.png'); % edit
32 fim = extract_features(im, FEATURE_EXTRACTION_METHOD);
33 % create emission probabilities matrix as requested by
35 X_viterbi = zeros(size(fim, 2), length(s));
36 for i=1:size(X_viterbi, 1)
37 fid = num2str(fim(:, i)'); % convert the feature to string -> feature id
38 X_viterbi(i, :) = X(X_ht.get(fid), :); % get this features' P(feature|state) for all states
41 disp('Inferring boundary 1, at last...');
42 inferred_sequence = hmm_forward_backward(s, S', X_viterbi);
44 show_result(im, inferred_sequence);