calculate_mean.m

来自「这是一个去马赛克工具软件」· M 代码 · 共 28 行

M
28
字号
function [m1,m2]=calculate_mean
%This function calculates the mean (a,b) components of the whole template
%set.

%Obtain all template names.
template_names=dir('../caras/*.jpg');
T=zeros(400,300,3);
M=makecform('srgb2lab');

for k=1:length(template_names)
    %Read image and convert it to Lab color space. Then add all of the
    %images.
    
    temp=imread(['../caras/',template_names(k).name]);
    temp=applycform(temp,M);
    k
    T=T+double(temp);
end

%Calculate the "average template"

T=T./length(template_names);

%Calculate the average values of (a,b) components of the "average
%template".

m1=mean(mean(T(:,:,2)));
m2=mean(mean(T(:,:,3)));

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?