MATLAB Answers


Calculating Fractal Dimension of 3D Object

Asked by Xander May on 30 May 2017
Latest activity Edited by Xander May on 30 May 2017
I want to calculate the fractal dimension of a 3D image that has been reconstructed from its images. The images are slices from an MRI machine. I have made a function to calculate the fractal dimension that is within 5% correctness on a 3D random cantor set. The function is as follows:
function dim = GetFracDim(PowerCount)
ToAvg = zeros(size(PowerCount).^2);
for i = 1:size(PowerCount)
for j = i+1:size(PowerCount)
ToAvg((i-1)*10+j) = (...
(log10(PowerCount(i)) - log10(PowerCount(j)))/...
(log10(2.^(9-(i-1))) - log10(2.^(9-(j-1)))));
ToAvg = ToAvg(ToAvg~=0)
dim = mean(ToAvg)
Which seems to work fine, again, for random data sets. Which leads me to believe that something in my image parsing code is wrong. However, I dont see how, as I can generate the 3D color images just fine, but perhaps the problem lies in creating the logical array. The code for image parsing is as follows:
for i = 1:HowManySlices
filename = [SlicesInDir(i).name];
slice = imread(filename);
slice(slice==255)=0; %Removing everything but the dead tissue
Slices(:,:,i) = slice; %Storing the images in greyscale for 3d reconstruction
%Turning array of doubles into a logical array
%This is for the fractal dimension
slice(slice==64)=1; %Grey is true
slice(slice==128)=1; %The other shade of grey is true
FractalMatrix(:,:,i) = slice;
However, when using my fractal dimension code on the data imported from that function, it states that the fractal dimension for this very 3d object is 2.0391.
Could it be the padding I do because the fractal counting must be done on powers of two?
%Convert whatever spacal array was given into something with
% sizes that are powers of two.
sizes = size(Space);
power = max([ceil(log10(sizes(1))/log10(2)),...
PaddedSpace = zeros(2.^power,2.^power,2.^power);
PaddedSpace(1:sizes(1),1:sizes(2),1:sizes(3)) = Space;
Space is the input 3D logical array.
I am at a loss as to what it could be at this point...


Sign in to comment.

0 Answers