3 dimensional fractal analysis

Hi,

I am interested in calculating 3D fractal dimension for the height of cancer cells using Atomic Force Microscopy. I know there are several methods available in current literature but I couldn’t find any algorithm online. Basically, I have a 512x512 pixel image with each pixel is corresponded to a certain height of the cell, which forms a 3D image in real life. I would prefer Matlab but any software that can solve the problem is welcomed. If anyone could steer me in the right direction I will be very grateful

Hi Kevin,
have you checked Matlab File Exchange? There are few packages that can be found with " 3D fractal dimension" search. For example:

From your explanation it is not clear what you would like to get as result.
Best regards,
Ilya

Dear @Ilya_Belevich,

I very much appreciate you taking the time to reply and share the link. I have looked into multiple Matlab packages but unfortunately they are not fit with my data. One of the major reasons is my input has a different format and when I test the code, it doesn’t give a correct fractal dimension as expected.

I am trying to calculate the fractal dimension for 3D surface obtained by Atomic Force Microscopy (basically it’s a scanning technique that allows measuring height in 3 dimensions), where it gives me 512x512 pixels. For each pixel, there is a value correlated to the height on the cell. So I have 262144 different values as expected.

I have not look into the link you share but will test it soon. Do you have any experience with this package before?

Please accept my thanks,
Kevin

I work with electron microscopy images but in my understanding, an AFM image is just a normal image where instead of intensities a height of cantilever is recorded.
What makes you format different?

Do you have any experience with this package before?

no, it just bumped among few others… I never worked with fractal dimensions

My input is 262144 different values for a 512x512 image, with each value corresponds to the height of a pixel. However, a package requires converting it to a binary 3D array (only 0 and 1), so I fill the cancer cell with 1 and the blank space with 0. When I calculate the fractal dimension, the result produced is almost the same for all the images I put in despite the height of is changing.

I have the hypothesis for why it acts the way it is. Since the code works perfectly fine for the image in a 3D space (imaging a 3D box that is randomly filled with 0 and 1 throughout the entire box), but when I put my data in, where the lower space is ONLY filled with 1 (since those are the “meat” of the cancer cell), and the upper space ONLY filled with 0 (since those are just air- blank space), the code does its job but calculate the fractal dimension for a different type of data.

So now I’m looking for any other Matlab package that has a different way to input data.

Kind regards,
K

so, you were able to convert 2D AFM image into 3D volume with 0/1s and tried to use it with that package above and it did not work?
Could it be because you actually need a surface rather than a filled block? I mean if you make a volume which will contain 1-s only at the interface between your call and air?
For example with code like this:

% as you probably have to work in physical units, you need to calculate the ratio between you xy and z dimensions
voxSize = [1 1 2];
zRatio = voxSize(1)/voxSize(2);

% for example, I just generated a random image
I = randi(255, [512 512]);
minVal = min(I(:)); % find min value
maxVal = max(I(:));  % find max value

% allocate space for 3D volume
V = zeros([512 512 round(maxVal*zRatio)], 'uint8');
% in loop populate all voxels below image intensity with 1s
for y=1:size(I, 1)
    for x=1:size(I, 1)
        V(y,x,round(I(y,x)*zRatio)) = 1;
    end
end

That’s actually an amazing idea, I will definitely try it out! Thank you so much for spending your valuable time to help.

Best wishes,
K

Dear @Ilya_Belevich,

Thank you for the code, I think your approach is correct. However, I have tried yours but I think I am a little bit unsure about the zRatio value.
The image I have is a square (3x3 um = 3000x3000nm). So I have a 3D box with each side is 3000nm. The height of the cancer cell is around 80-100 nm, do you know what should I put for the ratio there?

Kind regards,
Kevin

Hi Kevin,

It is aspect ratio of your voxels, which was used to calculate size of the volume with isotropic dimension. I assume that it is needed as the procedure works with binary 3D arrays (binary 3D arrays have no information about physical coordinates of your original dataset)

Your image is 512 x 512, which corresponds to 3 um. As result, pixel size is 3000/512=5.86 nm/pixel. Your heights are up to 100 nm, which corresponds to 100/5.86 = 17 pixels. In this sense, your final volume with isotropic voxels will be 512x512x17 and instead of “round(maxVal*zRatio)” you can put value 17 in the code.
Naturally 17 is quite small variation and I think that digitization of your signal is way better.
One possible solution is to work with anisotropic voxels and make a volume as 512x512x100, where your x/y resolution is 5.86 nm/pixel and the z-resolution 1 nm/pixel. Perhaps, procedure will still generate correct result (fractal dimension). I do not know in which way the result is expressed, if made of coordinates, the z-coordinate needs to be adjusted, i.e. divided by 5.86.

But I have not worked with that kind of data, so my suggestions are just general thoughts on how it may potentially be implemented.

I think you might be dealing with a self-affine fractal, not self-similar. Therefore the box counting method will not be appropriate because you will have the resize the box sizes according to scale.
Examples of self-affine objects are Earth’s mountain ranges, from far away they look flat, from close they are very irregular. You probably would get more meaningful results if you look at some frequency domain type of analysis (e.g. via the power spectrum or FFT of a transect of your cell height map, or the variogram method, or the R/S analysis). There is a known relation between the power spectrum exponent beta, the Hurst exponent and the fractal dimension D.

Dear @gabriel,

I think you are right, I knew something was wrong but couldn’t elaborate on it, I very much appreciate you pointing that out. Despite how I change the scale in z-direction it always gives the wrong value because it’s self-affine.
Do you have any experience with the fractal dimension similar to my kind of input data?

Thank you very much for taking the trouble to help. I will take a look into power spectrum and FFT

Kevin

However, I do find this on one of the build in program to calculate fractal dimension ,for the exact technique that I need, AFM. But indeed, it is self-affine

Cube counting method (cited)
The method is derived directly from a definition of box-counting fractal dimension. The algorithm is based on the following steps: a cubic lattice with lattice constant l is superimposed on the z-expanded surface. Initially l is set at X/2 (where X is length of edge of the surface), resulting in a lattice of 2×2×2 = 8 cubes. Then N(l) is the number of all cubes that contain at least one pixel of the image. The lattice constant l is then reduced stepwise by factor of 2 and the process repeated until l equals to the distance between two adjacent pixels. The slope of a plot of log(N(l)) versus log(1/l) gives the fractal dimension Df directly.

That is the box counting method in 3D, so it won’t work on self-affine sets.
I would take a look at spectral methods and compute several 1D transects over the AFM surface. Or the radial power spectrum.

You plot the power spectrum in log-log space, the slope (beta) of the plot relates to the fractal dimension of the surface as: D=(5-beta)/2.

Have a look in the literature, there are many references to this.

1 Like