to search fractal dimension

2 views (last 30 days)
This is already the segmentation stage, and I want to find the fractal dimension but it has an error. Can someone help me?
image_folder = 'F:\kuliah\semester6\TA2\mencoba\output';
outfolder = 'F:\kuliah\semester6\TA2\mencoba\hasil';
if ~isdir(outfolder); mkdir(outfolder); end
files = dir(fullfile(image_folder, '*.jpg'));
%I presume it has the variable map in it
for iFiles = 1:numel(files)
thisfilename = fullfile(files(iFiles).folder,files(iFiles).name);
[~, basename, ext] = fileparts(image_folder);
citra = imread(thisfilename);
%change to grayscale
grayimg = rgb2gray(citra);
figure, fig2=imshow(grayimg);
%change to green channel
green_channel = citra(:,:,2);
figure, fig3=imshow(green_channel);
%change to CLAHE (Contrast Limited Adaptive Histogram Equalization)
CLAHE = adapthisteq(green_channel);
figure, fig4=imshow(CLAHE);
ER = edge(CLAHE, 'canny');
EG = edge(CLAHE, 'canny');
EB = edge(CLAHE, 'canny');
anyedge = ER | EG | EB;
figure, fig5=imshow(anyedge)
fig = figure;
outfile = fullfile(outfolder, sprintf('%s-coba-%03d.jpg', basename, iFiles));
saveas(fig5, outfile);
% yang dihitung dimensinya yaitu citra hasil segmentasi
[n, r] = fboxcount(figure,'slope');
%Perhitungan dimensi
df = -diff(log(n))./diff(log(r));
%Menampilkan hasil dimensi
disp(['Df= ' num2str(mean(df(4:8)))]);
% % end

Accepted Answer

Walter Roberson
Walter Roberson on 13 Mar 2021
you are passing in something that isn't an rgb image.
Walter Roberson
Walter Roberson on 18 Mar 2021
Store the following code in the file named box_the_names.m
image_folder = 'F:\kuliah\semester6\TA2\mencoba';
files = dir(fullfile(image_folder, '*.jpg'));
filenames = fullfile({files.folder}, {});
filenames = char(filenames).';
filenames(end+1:ceil(size(filenames,1)/3)*3, :) = ' ';
filenames = rescale(double(filenames), 0, 1, 'InputMin', 32, 'InputMax', 127);
names_cmap = reshape(filenames, 3, []).';
[n, r] = fboxcount(names_cmap,'slope');
and use your existing fboxcount.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!