func_descendant.m

来自「对视频序列进行三维小波变换」· M 代码 · 共 64 行

M
64
字号
function value = func_Descendant(i, j, k, type, M)

% Matlab implementation of 3D-SPIHT (without Arithmatic coding stage)
%
% Find the descendant with largest absolute value of pixel (i,j,k) 
%
% input:    i : row coordinate
%           j : column coordinate
%           k : frame coordinate
%           type : type of descendant
%           M : whole video
%
% output:   value : largest absolute value
%
% This code is based on the implementation of the 2D-SPIHT by Jing Tian. It
% extends the code in order to handle 3d descendants.
%
%
% Athanasopoulos Dionysios 
% Postgraduate Student
% Computer Engineering and Informatics Dept.
% University of Patras, Greece
%

[s1,s2,s3] = size(M);
S = [];
index = 0; a = 0; b = 0; 

while ((2*i-1)<s1 & (2*j-1)<s2 & (2*k-1)<s3)
    a = i-1; b = j-1;

    mind = [2*(a+1)-1:2*(a+2^index)];
    nind = [2*(b+1)-1:2*(b+2^index)];
    zind = [2*k-1:2*k*(2^index)];
    
    chk = mind <= s1;
    len = sum(chk);
    if len < length(mind)
        mind(len+1:length(mind)) = [];
    end
    
    chk = nind <= s2;
    len = sum(chk);
    if len < length(nind)
        nind(len+1:length(nind)) = [];
    end
    
    chk = zind <= s3;
    len = sum(chk);
    if len < length(zind)
        zind(len+1:length(zind)) = [];
    end   
    
    S = [S reshape(M(mind,nind,zind),1,[])];
    
    index = index + 1;
    i = 2*a+1; j = 2*b+1;
end

if type == 1
    S(:,1:4) = [];; 
end

value = max(abs(S));

⌨️ 快捷键说明

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