File Exchange

## The Barycentric Fixed-Mass method for estimating fractal dimensions

version 1.2.0.0 (3.48 MB) by Yavor Kamer

### Yavor Kamer (view profile)

A method for estimating (multi) fractal properties of 2D/3D point distributions

Updated 17 Aug 2015

Multifractal dimension estimation with the Barycentric Fixed Mass method. Covers a given 2D/3D point distribution with equal mass circles/spheres centered at each point and then applies two additional criteria:
1) Barycentric: A circle/sphere is considered only if its center point is the closest point to its barycenter.
2) Non-Overlapping: Barycentric circles/spheres are randomly chosen such that the overlap is minimized while maximizing the overall coverage

For detailed information check the following publication:
Y. Kamer, G. Ouillon and D. Sornette (2013) Barycentric fixed-mass method for multifractal analysis http://arxiv.org/abs/1305.7384

% EXAMPLE:
% Generate a 3D monofractal with D=1.58...
mat_p1 = [0 1; 0 0];
mat_p1(:,:,2) = [1 0; 1 0];
pts_mat = recursiveFrac(mat_p1,7);
% ...and estimate D(q) vs q using BFM
[q_vec, Dq_vec] = call_BFM(pts_mat);
plot(q_vec, Dq_vec, '.-k');

### Cite As

Yavor Kamer (2020). The Barycentric Fixed-Mass method for estimating fractal dimensions (https://www.github.com/y-kamer/BFM), GitHub. Retrieved .

lvapple

### lvapple (view profile)

1. As the output parameter are only 'q' and 'Dq', I use the two parameters to calculate other parameters "tao=Dq_vec.*q_vec; alfa=diff(tao)./diff(q_vec); f=q_vec(1:end-1).*alfa-tao(1:end-1);" to draw the figures 'tao(q)-q' ' Dq-hq'. Could you increase the output parameters of the 'bfmFinalFx.p' and I need not calculate them with above codes?
2. The last figure after running your program is nice, could you put the codes plotting the last figure out of the 'bfmFinalFx.p' ? I want to plot other figures using it.
lvapple

Yavor Kamer

### Yavor Kamer (view profile)

Hi Ivapple,
If you have a grayscale image then you can create 2D points by thresholding. You can get the coordinates of the pixels exceeding certain values and then use those points to do the BFM analysis. Here is a simple code that does that. You might consider adding a random perturbation to your pixel coordinates [pX, pY] (within 1 pixel) otherwise the tessellation code might complain.
Best wishes,
yavor

%% Create synthetic grayscale image
imgGS = propsSynthesizeImage;
imgGS = imgGS .* cast(rand(size(imgGS)),'uint8');
[nR,nC] = size(imgGS);
%% Threshold at different levels and create point cloud
thLvl = 1:30:intmax('uint8'); % threshold levels
ptsCell = cell(numel(thLvl),1); % points
figure;
for i=1:numel(thLvl)
subplot(3,3,i)
[pX,pY] = ind2sub([nR nC],find(imgGS>thLvl(i))); %convert indices to coordinates
ptsCell{i} = [pX pY];
plot(pX,pY,'.');
title(['Threshold : ' num2str(thLvl(i))])
end

lvapple

### lvapple (view profile)

Hi Kamer, your example about 3D figure works well, and I need calculate the 2D figure. However, the input ('pts_mat') of the call_BFM function is a matrix with 2187*3 for the 3D figure,and each row of the matrix is a 3D point. What should I do for the 2D figure or photograph? How can I get the matrix ? Can you give an example for the 2D figure when the input is a photograph? Looking forward to your reply!

Yavor Kamer

### Yavor Kamer (view profile)

monkey:
i'm glad it worked, kudos to you for still running R2006, i learned matlab on that version, classics never die :)

monkey

### monkey (view profile)

Yavor Kamer:
thanks very much!
I think that the occurrence of this error has a relationship with the version of the software.
It works well when run in the version of Matlab.R2015ax64(8.5), but not in the version of MATLAB R2006b.

Best wishes

Yavor Kamer

### Yavor Kamer (view profile)

monkey: interesting error. i can imagine you getting this error only by overriding the bfmFinalFx function with 3 inputs arguments instead of the 2 that are provided in the call_BFM. What version of Matlab are you using? Did you modify the prm structure defined in call_BFM?

monkey

### monkey (view profile)

There is a error in "bfmFinalFx.p".
it is the details:

>> mat_p1 = [0 1; 0 0];
mat_p1(:,:,2) = [1 0; 1 0];
pts_mat = recursiveFrac(mat_p1,7);
[q_vec, Dq_vec] = call_BFM(pts_mat);
??? Error: File: bfmFinalFx.p Line: 186 Column: 0
Expression or statement is incomplete or incorrect.

Error in ==> call_BFM at 58
[q_vec, Dq_vec] = bfmFinalFx(pts_mat,prm);