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);
Slices(:,:,i) = slice;
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?
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...