我试图在MATLAB上实现主动外观模型的光度标准化步骤,如此处所述http://www2.imm.dtu.dk/~aam/main/node13.html#SECTION04350000000000000000
我的代码如下:
function g=AAM_NormalizeAppearance3D(gim_mat)
n_texs = size(gim_mat,1); % Number of array elements
s = size(gim_mat,2); % Number of textures
mean_tex = gim_mat(:,1); % First mean texture is considered to be the first one in the set
tex_error = 1;
oneloop = false;
while tex_error > 0.001 % Convergence criteria
mean_tex = mean_tex - mean(mean_tex); % Standardize mean texture
sig = sqrt(sum(mean_tex.^2)/n_texs);
mean_tex = mean_tex/sig;
if oneloop % prev_mean_tex is still not defined in first iteration
tex_error = sum(abs((prev_mean_tex - mean_tex)));
end
for i=1:s
alpha = dot(gim_mat(:,i), mean_tex);
beta = mean(gim_mat(:,i));
gim_mat(:,i) = (gim_mat(:,i) - beta)/ alpha; % Normalized texture vector
end
prev_mean_tex = mean_tex; % Store previous mean texture
mean_tex = mean(gim_mat,2); % New mean texture
oneloop = true;
end
g = gim_mat;
现在,我不知道我是否解释了我从中得到的结果或者代码中是否有任何错误,但我得到的标准化纹理值非常小。也就是说,对于值范围从0到1的输入纹理矢量,我得到具有10 ^ -5数量级的最大值的归一化矢量。难道这不会收敛到更高的值吗?