find fractal dimension value

i have the code to find fractal dimension value, but the image limit that can be calculated is only up to 512 x 512. So here I want this code to be able to search up to 2048 x 2048. Can you help me sir?
This is the code:
Thankyou in advance sir.

 Accepted Answer

Walter Roberson
Walter Roberson on 12 Jul 2021
Adjusted code attached. I also repaired an error in it (it was confusing x and y).
The adjusted code does not require that the image is square, or an exact power of 2. However, it might ignore parts of the image outside the last full square power of 2 size.
The adjusted code uses baby.jpg as the same image to read, which is 3600 x 2450 or so. The program slows down a lot after i = 9.

11 Comments

thank you sir, after i try it works. but I want to find the value of the fractal dimension of the white line. and after I apply it becomes an error sir.
This is the example of image:
Thankyou sir
What error do you see? I ran the code with that file and do not encounter any error.
Note: I would suggest that you might want to trim out the white border around the part of interest.
like this sir
this should be the desired result sir
Modify to
ymin=floor(kolom_kotak*tinggi_setiap_kotak)+1;
ymax=(ymin+floor(tinggi_setiap_kotak))-1;
xmin=floor(baris_kotak*lebar_setiap_kotak)+1;
xmax=(xmin+floor(lebar_setiap_kotak))-1;
Why would the output be what you posted above? That output is for a 64 x 64 image, but your image is 543 by 774
its work sir, thankyou so much sir. But sir, can this code be a function sir? So its just calls this function in other code.
Sir, i want to ask again. How to invert the image so that the background iss white and and the line becomes white.
Function version attached.
format long g
filename = 'https://www.mathworks.com/matlabcentral/answers/uploaded_files/682113/ISIC_0053549-CannyGreen.jpg';
img = imread(filename);
rimg = 255-img;
fd = fdtest1(rimg)
ukuran = 1×2
945 1072
i -> r=2^i -> n(r) i -> Banyak Kotak (rxr) -> Banyak Kotak yg dilewati Gambar 0 -> 1 -> 1 1 -> 2 -> 4 2 -> 4 -> 16 3 -> 8 -> 59 4 -> 16 -> 189 5 -> 32 -> 675 6 -> 64 -> 2519 7 -> 128 -> 9669 8 -> 256 -> 35856 9 -> 512 -> 115414
fd = 1×2
1.86386575846367 0.100772652497056
Have you considered the possibility that you should be cropping your image?
i found the error sir
You asked for a function form, I provided a function form. I also provided example code of how to call the function.
If you are not intending to pass image data or an image file name to the function, then how do you intend for the function to get information about what data it should work with? If the intention is that the function should prompt the user to select a file, then you should have said that.
its work sir, thankyou so much

Sign in to comment.

More Answers (0)

Categories

Find more on Fractals in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!