FRACLAB Functions | ![]() ![]() |
Box dimension, computed with the box method, of the white points in a black and white image or, more generally, of non-zero-points in an N-dimensional array.
Syntax
[boxdim,Nboxes,handlefig]=boxdim_binaire(BWimg, Size, Ratio, Axes, Waitbar ,reg, lrstr, optvarargin)
Inputs
BWimg
N-dimensional array. Usually, it is a matrix containing 0 and 1. If BWImg contains values different from 0 and 1, all non-zero values are trated as ones.
Size, Ratio
:
Ratio defines the lengths of the sides of a "first box". If BWimg is an image, it is a 1x2 array. (1xN array if BWimg is an N dimensional array). The successive boxes will be deduced from this first box by homotheties with ration Size(i). More precisely, the box at at the i - th iteration will have a length along the k - th axis equal to Ratio(k)*Size(i)
Axes
:
Waitbar
:
1 if you want a waitbar to appear during the calculation, else 0
reg
:
The way you choose the bounds. See the help on fl_regression for more information.
lrstr,optvarargin
:
Regression parameters. They define the regression type. Type " help monolr" for more information
Outputs
boxdim
:
The estimated box dimension
Nboxes
:
Nboxes is a vector. Nboxes(i) is the number of non-empty boxes at the i - th iteration. A non-empty box is a box that contains at least one point of the graph of the function.
handlefig
:
If reg~=0, a window appears to help you choosing the linearity bounds. handlefig is the handle of this figure.
bounds
:
Bounds of linearity of log2(Nboxes) in function of log2(Size). Interesting if reg==1.
Optional arguments
Size=[1 1/2 1/4 ... 1/2048 1/4096]
Ratio =[1 1 ...]
Axes=[0 1;0 1 ; ...]
Waitbar = 0
reg=0
lrstr='ls'
These default values are not always relevant, especially Size, so when you don't know how to define Size, try to use reg ~= 0 in order to precise manually the correct box sizes.
Example 1
This drawing may help you to understand the roles of Size and Ratio.
load('image_Weierstrass.mat');
imagesc(C);colormap('gray');%display C
Size=[1/2,1/4];
Ratio=[1,4];
Axes=[0,1;0,4];
% To avoid the extrema points to be counted in separated boxes
epsi=10^(-3);
Axes=Axes+[epsi,-epsi;epsi,-epsi];
% Calculation
[boxdim,Nboxes,handlefig]=boxdim_binaire(C, Size, Ratio,Axes)
Example: Computes the box dimension of a self-similar image. Its theorical dimension is log(7)/log(3)=1.77
% load the image
load('fleche.mat');
% Plot the image
figure;imagesc(fleche);colormap('gray');pause;
% Compute its box dimension
reg=1;
Waitbar=1;
[boxdim,Ntailles,handlefig,bounds]=boxdim_binaire(fleche,[],[],[],Waitbar,reg);
boxdim
bounds
% You should find bounds = -9 -3. It means that
% the progression is linear when log2(size) is in [-9 -3]. You may keep these
% bounds, take more points and try another regression type.
reg=0;
Size=2.^[-9 : 0.5 : 0-3];
boxdim=boxdim_binaire(fleche,Size,[],[],Waitbar,reg,'pls',30);
boxdim
See Also