func_morton.m

来自「EZW matlab 源码用于图像压缩试验」· M 代码 · 共 17 行

M
17
字号
function scan = func_morton(pos,n);

%  The matrix should be n by n
%  For position we start counting from 0
%
%  position = [0:(n*n)-1];
%  scan = morton(position, n);
%  Copyright 2002  Paschalis Tsiaflakis, Jan Vangorp
%  Revision 1.0  10/11/2002 19.00u

bits = log2(n*n); % number of bits needed to represent position
bin = dec2bin(pos(:),bits); % convert position to binary

% odd bits represent row number
% even bits represent column number

scan = [bin2dec(bin(:,1:2:bits-1)), bin2dec(bin(:,2:2:bits))];

⌨️ 快捷键说明

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