德国数学家David Hilbert发现了一种曲线,首先把一个正方形等分成四个小正方形,依次从西南角的正方形中心出发往北到西北正方形中心,再往东到东北角的正方形中心,再往南到东南角正方形中心,这是一次迭代,如果对四个小正方形继续上述过程,往下划分,反复进行,最终就得到一条可以填满整个正方形的曲线,这就是Hibert曲线。
这种曲线有一个很好的优点,它可以将二维图像信号转为一维信号,在进行处理,这样就可以避免二维图像处理中的块效应。同时用一维小波处理信号时比二维小波处理图像更好,因为二维小波严格来说是伪小波,不是全方位的。
这是实现hilbert曲线的matlab程序
function [x,y] = hilbert(n)
% [X,Y] = HILBERT(N) calculates and returns the co-ordinates of
% the nodes of the n-th iteration of Hilbert's space-filling curve
% using recursion.
% It also draws the curve at the n-th iteration.
% [X,Y] = HILBERT uses N = 4.
% This file was generated by students as a partial fulfillment
% for the requirements of the course "Fractals", Winter term
% 2004/2005, Stuttgart University.
% Author : Melanie Reichner, Jonas Offtermatt
% Date : Nov 2004
% Version: 1.0
%default setting
if nargin ~= 1
n = 4;
end
% end of recursion
if n <= 0
x = 0;
y = 0;
%recursive method call
else
[x0,y0] = hilbert(n-1);
%calculate new co-ordinates
x = .5*[-.5+y0 -.5+x0 .5+x0 .5-y0];
y = .5*[-.5+x0 .5+y0 .5+y0 -.5-x0];
end
plot(x,y,'-');
axis off;
当取 n = 4 时;如图