1
function pw = rgb2pw(pwc, alg)
2
fMi = 40.0/60.0; % ÷àñòîòà ñðåçà äëÿ 40 óä/ìèí (0.6667 Ãö)
6
% Èíôîðìàòèâíûå ñèãíàëû äëÿ ôîðìèðîâàíèÿ ïóëüñîâûõ âîëí ïî öâåòîâûì êàíàëàì
7
% Öâåòîâûå êàíàëû: 1->R; 2->G; 3->B
14
pw = pwc(:,2)-pwc(:,1);
18
pw = (112.0*pwc(:,1)-93.8*pwc(:,2)-18.2*pwc(:,3))./255.0;
19
pw=pw-movmean(pw,32); % Âû÷èòàåì òðåíä
23
ws(:,1) = (3.0*pwc(:,1)-2.0*pwc(:,2))./sqrt(13.0);
24
ws(:,2) = (-1.5*pwc(:,1)-pwc(:,2)+1.5*pwc(:,3))./sqrt(11.0/2.0); % óìíîæåíî íà (-1) äëÿ pw=ws(:,1)+ws(:,2)
28
ws(:,1) = (pwc(:,2)-pwc(:,3))./sqrt(2.0);
29
ws(:,2) = (pwc(:,2)+pwc(:,3)-2.0*pwc(:,1))./sqrt(6.0);
32
%% Öåíòðèðîâàííàÿ è íîðìèðîâàííàÿ ïóëüñîâàÿ âîëíà pw
33
SMO_med = floor(cad/fMi);
35
if alg=="G" || alg=="GR" || alg=="Cr"
37
DEV_med = medfilt1(pw2,SMO_med);
38
STD_med(:,1) = sqrt(DEV_med);
39
pw = pw./STD_med(:,1);
42
if alg=="CHROM" || alg=="POS"
43
DEV_med = medfilt1(ws(:,1).*ws(:,1),SMO_med); STD_med(:,1) = sqrt(DEV_med);
44
DEV_med = medfilt1(ws(:,2).*ws(:,2),SMO_med); STD_med(:,2) = sqrt(DEV_med);
45
pw = (ws(:,1)./STD_med(:,1))+(ws(:,2)./STD_med(:,2));
46
[iPer, D_time] = iPer(video, pw, alg);
47
HRV (video, iPer, D_time, alg);
50
% Àíàëèç àíîìàëüíûõ çíà÷åíèé
51
prcMi = prctile(pw,0.1);
52
prcMa = prctile(pw,99.9); % ïðîöåíòèëè ïî óðîâíÿì 0.1% è 99.9%
62
pw = pw./STD; % íîðìèðîâàííàÿ pw