分形维数盒子算法


国外大牛写的分形维数的例子,包含盒子算法等有用的函数
资源截图
代码片段和文件信息
function [nr] = boxcount(cvarargin)
%BOXCOUNT  Box-Counting of a D-dimensional array (with D=123).
%   [N R] = BOXCOUNT(C) where C is a D-dimensional array (with D=123)
%   counts the number N of D-dimensional boxes of size R needed to cover
%   the nonzero elements of C. The box sizes are powers of two i.e. 
%   R = 1 2 4 ... 2^P where P is the smallest integer such that
%   MAX(SIZE(C)) <= 2^P. If the sizes of C over each dimension are smaller
%   than 2^P C is padded with zeros to size 2^P over each dimension (e.g.
%   a 320-by-200 image is padded to 512-by-512). The output vectors N and R
%   are of size P+1. For a RGB color image (m-by-n-by-3 array) a summation
%   over the 3 RGB planes is done first.
%
%   The Box-counting method is useful to determine fractal properties of a
%   1D segment a 2D image or a 3D array. If C is a fractal set with
%   fractal dimension DF < D then N scales as R^(-DF). DF is known as the
%   Minkowski-Bouligand dimension or Kolmogorov capacity or Kolmogorov
%   dimension or simply box-counting dimension.
%
%   BOXCOUNT(C‘plot‘) also shows the log-log plot of N as a function of R
%   (if no output argument this option is selected by default).
%
%   BOXCOUNT(C‘slope‘) also shows the semi-log plot of the local slope
%   DF = - dlnN/dlnR as a function of R. If DF is contant in a certain
%   range of R then DF is the fractal dimension of the set C.
%
%   The execution time depends on the sizes of C. It is fastest for powers
%   of two over each dimension.
%
%   Examples:
%
%      % Plots the box-count of a vector containing randomly-distributed
%      % 0 and 1. This set is not fractal: one has N = R^-2 at large R
%      % and N = cste at small R.
%      c = (rand(12048)<0.2);
%      boxcount(c);
%
%      % Plots the box-count and the fractal dimension of a 2D fractal set
%      % of size 512^2 (obtained by BOXDIV) with fractal dimension
%      % DF = 2 + log(P) / log(2) = 1.68 (with P=0.8).
%      c = randcantor(0.8 512 2);
%      boxcount(c);
%      figure boxcount(c ‘slope‘);
%
%   F. Moisy
%   Revision: 2.00  Date: 2006/11/22


% History:
% 2006/11/22: joins into a single file boxcountn (n=123).


% control input argument
error(nargchk(12nargin));

% check for true color image (m-by-n-by-3 array)
if ndims(c)==3
    if size(c3)==3 && size(c1)>=8 && size(c1)>=8
        c = sum(c3);
    end;
end;

warning off
c = logical(squeeze(c));
warning on

dim = ndims(c); % dim is 2 for a vector or a matrix 3 for a cube
if dim>3
    error(‘Maximum dimension is 3.‘);
end

% transpose the vector to a 1-by-n vector
if length(c)==numel(c)
    dim=1;
    if size(c1)~=1   
        c = c‘;
    end   
end

width = max(size(c));    % largest size of the box
p = log(width)/log(2);   % nbre of generations

% remap the array if the sizes are not all equal
% or if they are not power of two
% (this slows down the computation!)
if p~=round(p) || any(size(c)~=width)
    p = ceil(p);
    width = 2^p

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      37254  2006-11-14 13:04  box-countingApollonian_gasket.gif

     文件       5587  2006-11-21 12:43  box-countingoxcount.m

     文件        198  2006-11-21 12:40  box-countingContents.m

     文件       4998  2006-11-21 12:50  box-countingdemo.m

     文件      30608  2006-11-21 00:00  box-countingdla.gif

     文件    1125602  2006-11-20 17:03  box-countingfractal_tree.jpg

     文件      15947  2006-11-21 12:57  box-countinghtmldemo.html

     文件       1541  2006-11-21 12:57  box-countinghtmldemo.png

     文件      17927  2006-11-21 12:57  box-countinghtmldemo_01.png

     文件       4913  2006-11-21 12:57  box-countinghtmldemo_02.png

     文件       5947  2006-11-21 12:57  box-countinghtmldemo_03.png

     文件       4489  2006-11-21 12:57  box-countinghtmldemo_04.png

     文件       8783  2006-11-21 12:57  box-countinghtmldemo_05.png

     文件       5058  2006-11-21 12:57  box-countinghtmldemo_06.png

     文件       4576  2006-11-21 12:57  box-countinghtmldemo_07.png

     文件     347480  2006-11-21 12:57  box-countinghtmldemo_08.png

     文件      19070  2006-11-21 12:57  box-countinghtmldemo_09.png

     文件       4738  2006-11-21 12:57  box-countinghtmldemo_10.png

     文件      15346  2006-11-21 12:57  box-countinghtmldemo_11.png

     文件       4383  2006-11-21 12:57  box-countinghtmldemo_12.png

     文件       5297  2006-11-21 12:57  box-countinghtmldemo_13.png

     文件       2329  2006-11-21 12:57  box-countinghtmldemo_14.png

     文件       4747  2006-11-21 12:57  box-countinghtmldemo_15.png

     文件       3714  2006-11-21 12:57  box-countinghtmldemo_16.png

    ..A.SH.     45056  2008-05-27 10:59  box-countinghtmlThumbs.db

    ..AD...         0  2006-11-21 12:57  box-countinghtml

     文件       5221  2006-11-21 12:42  box-counting
andcantor.m

     目录          0  2008-05-24 21:46  box-counting

----------- ---------  ---------- -----  ----

              1731027                    29

............此处省略2个文件信息

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)