⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 func_spiht_enc.m

📁 4-D SPHIT 压缩Matlab 程序
💻 M
📖 第 1 页 / 共 2 页
字号:
                    sgn = M(2*x-1,2*y,2*z ,2*t-1)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x-1 2*y 2*z 2*t-1];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y-1,2*z,2*t-1)) >= 2^n
                    LSP = [LSP; 2*x 2*y-1 2*z 2*t-1];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y-1,2*z,2*t-1)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y-1 2*z 2*t-1];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y,2*z),2*t-1) >= 2^n
                    LSP = [LSP; 2*x 2*y 2*z 2*t-1];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y,2*z,2*t-1)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y 2*z 2*t-1];
                end
                if abs(M(2*x-1,2*y-1,2*z-1,2*t)) >= 2^n
                   LSP = [LSP;2*x-1 2*y-1 2*z-1 2*t];
                   out(index) = 1; bitctr = bitctr + 1;
                   index = index +1; Bits_LIS = Bits_LIS + 1;
                   sgn = M(2*x-1,2*y-1,2*z-1,2*t)>=0;
                   out(index) = sgn; bitctr = bitctr + 1;
                   index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; LISx LISy LISz LISt];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x-1,2*y,2*z-1,2*t)) >= 2^n
                    LSP = [LSP; 2*x-1 2*y 2*z-1 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x-1,2*y,2*z-1,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x-1 2*y 2*z-1 2*t];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y-1,2*z-1,2*t)) >= 2^n
                    LSP = [LSP; 2*x 2*y-1 2*z-1 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y-1,2*z-1,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y-1 2*z-1 2*t];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y,2*z-1,2*t)) >= 2^n
                    LSP = [LSP; 2*x 2*y 2*z-1 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y,2*z-1,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y 2*z-1 2*t];
                end

                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x-1,2*y-1,2*z,2*t)) >= 2^n
                    LSP = [LSP; 2*x-1 2*y-1 2*z 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x-1,2*y-1,2*z,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x-1 2*y-1 2*z 2*t];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x-1,2*y,2*z,2*t)) >= 2^n
                    LSP = [LSP; 2*x-1 2*y 2*z 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x-1,2*y,2*z ,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x-1 2*y 2*z 2*t];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y-1,2*z,2*t)) >= 2^n
                    LSP = [LSP; 2*x 2*y-1 2*z 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y-1,2*z,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y-1 2*z 2*t];
                end
                
                if (bitctr + 1) >= max_bits
                    if (bitctr < max_bits)
                        out(length(out))=[];
                    end
                    return
                end
                if abs(M(2*x,2*y,2*z),2*t) >= 2^n
                    LSP = [LSP; 2*x 2*y 2*z 2*t];
                    out(index) = 1; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    sgn = M(2*x,2*y,2*z,2*t)>=0;
                    out(index) = sgn; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                else
                    out(index) = 0; bitctr = bitctr + 1;
                    index = index +1; Bits_LIS = Bits_LIS + 1;
                    LIP = [LIP; 2*x 2*y 2*z 2*t];
                end
  
                if ((2*(2*x)-1) < size(M,1) & (2*(2*y)-1) < size(M,2) & (2*(2*z)-1) < size(M,3) & (2*(2*t)-1) < size(M,4))
                    LIS = [LIS; LIStemp(i,1) LIStemp(i,2) LIStemp(i,3) LIStemp(i,4) 1];
                    LIStemp = [LIStemp; LIStemp(i,1) LIStemp(i,2) LIStemp(i,3) LIStemp(i,4) 1];
                end
                LIS(temp,:) = []; temp = temp-1;
                
            else
                out(index) = 0; bitctr = bitctr + 1;
                index = index +1; Bits_LIS = Bits_LIS + 1;
            end
        else
            if bitctr >= max_bits
                return
            end
            max_d = func_Descendant(LIStemp(i,1),LIStemp(i,2),LIStemp(i,3),LIStemp(i,4),M);
            if max_d >= 2^n
                out(index) = 1; bitctr = bitctr + 1;
                index = index +1;
                x = LIStemp(i,1); y = LIStemp(i,2); z = LIStemp(i,3); t = LIStemp(i,4);
                LIS = [LIS; 2*x-1 2*y-1 2*z-1 2*t-1 0; 2*x-1 2*y 2*z-1 2*t-1 0; 2*x 2*y-1 2*z-1 2*t-1 0; 2*x 2*y 2*z-1 2*t-1 0;
                            2*x-1 2*y-1 2*z 2*t-1 0; 2*x-1 2*y 2*z 2*t-1 0; 2*x 2*y-1 2*z 2*t-1 0; 2*x 2*y 2*z 2*t-1 0;
                            2*x-1 2*y-1 2*z-1 2*t 0; 2*x-1 2*y 2*z-1 2*t 0; 2*x 2*y-1 2*z-1 2*t 0; 2*x 2*y 2*z-1 2*t 0;
                            2*x-1 2*y-1 2*z 2*t 0; 2*x-1 2*y 2*z 2*t 0; 2*x 2*y-1 2*z 2*t 0; 2*x 2*y 2*z 2*t 0;];
                LIStemp = [LIStemp; 2*x-1 2*y-1 2*z-1 2*t-1 0; 2*x-1 2*y 2*z-1 2*t-1 0; 2*x 2*y-1 2*z-1 2*t-1 0; 2*x 2*y 2*z-1 2*t-1 0;
                                    2*x-1 2*y-1 2*z 2*t-1 0; 2*x-1 2*y 2*z 2*t-1 0; 2*x 2*y-1 2*z 2*t-1 0; 2*x 2*y 2*z 2*t-1 0;
                                    2*x-1 2*y-1 2*z-1 2*t 0; 2*x-1 2*y 2*z-1 2*t 0; 2*x 2*y-1 2*z-1 2*t 0; 2*x 2*y 2*z-1 2*t 0;
                                    2*x-1 2*y-1 2*z 2*t 0; 2*x-1 2*y 2*z 2*t 0; 2*x 2*y-1 2*z 2*t 0; 2*x 2*y 2*z 2*t 0;];
                LIS(temp,:) = []; temp = temp - 1;
            else
                out(index) = 0; bitctr = bitctr + 1;
                index = index +1; Bits_LIS = Bits_LIS + 1;
            end
        end
        i = i+1;
    end
    
     %---------------------------Refinement Pass---------------------
    temp = 1;
    value = floor(abs(2^(n_max-n+1)*M(LSP(temp,1),LSP(temp,2),LSP(temp,3),LIS(temp,4))));
    while (value >= 2^(n_max+2) & (temp <= size(LSP,1)))
        if bitctr >= max_bits
            return
        end
        s = bitget(value,n_max+2);
        out(index) = s; bitctr = bitctr + 1;
        index = index +1; Bits_LSP = Bits_LSP + 1;
        temp = temp + 1;
        if temp <= size(LSP,1)
            value = floor(abs(2^(n_max-n+1)*M(LSP(temp,1),LSP(temp,2),LSP(temp,3),LIS(temp,4))));
        end
    end
    
    n = n - 1;
end

⌨️ 快捷键说明

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