-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcolorgradient_mg_mug.m
34 lines (26 loc) · 1.14 KB
/
colorgradient_mg_mug.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
function [LMN_mg, LMN_mug] = colorgradient_mg_mug(pointset, center, weight)
% G = G_d;
% pointset = pointset_d;
% center = center_d;
% w = full(G.W);
pointset_color = pointset(:, 4:6);
pointset_color = pointset_color/255;
[L,M,N] = RGB2LMN_graph(pointset_color);
pointset_color_lmn = [L,M,N];
[c_L,c_M,c_N] = RGB2LMN_graph(center(4:6));
center_color_lmn = [c_L, c_M, c_N];
center_index = find(ismember(pointset(:,1:3),center(1,1:3),'rows')==1);
center_index = center_index(1);
w_center = sqrt(weight)';
% l_local = w_center .* (c_L - pointset_color_lmn(:,1));
% m_local = w_center .* (c_M - pointset_color_lmn(:,2));
% n_local = w_center .* (c_N - pointset_color_lmn(:,3));
l_local = w_center .* (pointset_color_lmn(center_index, 1) - pointset_color_lmn(:,1));
m_local = w_center .* (pointset_color_lmn(center_index, 2) - pointset_color_lmn(:,2));
n_local = w_center .* (pointset_color_lmn(center_index, 3) - pointset_color_lmn(:,3));
local_mg = sum([l_local,m_local,n_local]);
LMN_mg = single(local_mg);
number = size(pointset,1)-1;
local_mug = local_mg/number;
LMN_mug = single(local_mug);
LMN_mug(isnan(LMN_mug)) = 0;