-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuzzy_kappa_demo.m
95 lines (82 loc) · 3.02 KB
/
fuzzy_kappa_demo.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
88
89
90
91
92
93
% =======================================================================
% Copyright 2022
% Author: Alex Hagen-Zanker
% University of Surrey
%
% Distributed under the MIT Licence (http://opensource.org/licenses/MIT)
% =======================================================================
%
clear variables; close all; clc
A1 = [0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 1 1 1 1 1 0 0 0; ...
0 0 0 1 1 0 1 0 0 0; ...
0 0 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0];
B1 = [0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 1 1 0; ...
0 0 0 0 0 1 1 1 1 0; ...
0 0 0 0 0 1 1 1 1 0; ...
0 0 0 0 0 0 0 0 0 0];
A2 = [0 0 0 0 0 1 0 0 0 0; ...
0 0 1 0 0 0 0 0 0 0; ...
0 0 0 1 1 0 0 0 0 0; ...
0 0 0 1 0 0 0 0 0 0; ...
0 0 0 0 1 0 0 0 0 0; ...
0 0 0 1 0 0 0 0 0 0; ...
0 0 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 1 0 0 0 0 0; ...
0 0 0 1 0 0 0 0 0 0];
B2 = [0 0 0 0 0 0 0 0 0 0; ...
0 0 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 0 1 0 0 0; ...
0 1 0 0 0 0 1 0 0 0; ...
0 0 0 0 0 0 0 0 0 1; ...
0 0 0 0 0 1 0 0 0 1; ...
0 0 0 0 0 0 0 0 0 0; ...
0 1 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0 0; ...
1 0 0 0 0 0 0 0 0 0];
A3 = readmatrix("Map1.asc","NumHeaderLines",5,"Delimiter"," ","FileType","text");
B3 = readmatrix("Map3.asc","NumHeaderLines",5,"Delimiter"," ","FileType","text");
M3 = eye(4);
Mask3 = readmatrix("Mask.asc","NumHeaderLines",5,"Delimiter"," ","FileType","text");
halving_distance = 2;
f3 = @(d)exp(log(1/2) * d / halving_distance);
Mask = ones(10);
M = eye(2);
f = @(d)(d <= 1.01) * 0.5 + (d <= 0.5) * 0.5;
[fk, sim, P, E] = fuzzy_kappa(A1, B1, M, Mask, f);
h = subplot(3,3,1); imagesc(A1+1);title("A")
h(end + 1) = subplot(3,3,2); imagesc(B1+1);title("B")
h(end + 1) = subplot(3,3,3); imagesc(sim);
title("Sim (FK: " + fk + newline + "P: " + P + ", E: " + E + ")")
[fk, sim, P, E] = fuzzy_kappa(A2, B2, M, Mask, f);
h(end + 1) = subplot(3,3,4); imagesc(A2+1);title("A")
h(end + 1) = subplot(3,3,5); imagesc(A2+1);title("B")
h(end + 1) = subplot(3,3,6); imagesc(sim);
title("Sim (FK: " + fk + newline + "P: " + P + ", E: " + E + ")")
[fk, sim, P, E] = fuzzy_kappa(A3, B3, M3, Mask3, f3);
h(end + 1) = subplot(3,3,7); image(A3+1, 'AlphaData', Mask3);title("A")
h(end + 1) = subplot(3,3,8); image(B3+1, 'AlphaData', Mask3);title("B")
h(end + 1) = subplot(3,3,9); imagesc(sim, 'AlphaData', Mask3);
title("Sim (FK: " + fk + newline + "P: " + P + ", E: " + E + ")")
colorbar
set(h, 'XTick', []);
set(h, 'YTick', []);
axis(h,'square')
set(h,'Color',[0.9 0.9 0.9])
demo_colors = [1 1 0.5;1 0 0;0 0 1;0 1 0];
set(h([1,2,4,5]), 'Colormap',[1 1 1; 0 0 0]);
set(h([7,8]),'Colormap',demo_colors)
set(h([3,6,9]),'Colormap',gray)