資源簡介
輸入灰度圖像,RGB彩色圖像會自動轉(zhuǎn)換為灰度圖像
輸出圖像的多重分形譜
參考文獻(xiàn):
"fractal analysis and multifractal spectra for the images"
代碼片段和文件信息
%Name:multifractal_and_output
%Author:Jia?MenghanZhejiang?University?
%Date:?2013/9/3
%Description:
%?輸入灰度圖像RGB彩色圖像會自動轉(zhuǎn)換為灰度圖像
%?輸出圖像的多重分形譜
%Reference:
%?“fractal?analysis?and?multifractal?spectra?for?the?images“
%
%?Prof.?Artde?D.K.T.?Lam?Ph.D
%?Department?of?Information?Communication
%?Leader?University
%?70901?Tainan?City?Taiwan
%?e-mail:?artde.lam@gmail.com
%?
%?Asso.?Prof.?Q.?Li
%?Department?of?Digital?Media?Arts
%?Fuzhou?University
%?350108?Fuzhou?Fujian
%?e-mail:?fzuliqi@126.com
%
%%?設(shè)定q范圍
clc;close?all;
clear?all;
qmin=-50.5;
qmax=50.5;
qevery=1;
%%?讀取圖片
[filenamepathnamefilterindex]=uigetfile(‘*.*‘‘選擇要打開的圖片文件‘);
filename=[pathname?filename];
a?=?imread(filename);
%?a=a(1:641:64);
[rows?cols]?=?size(a);
if?mod(log2(rows)1)>0
????error(‘The?size?of?image?must?be?2^n‘);
end
if?size(a3)==3
????a=rgb2gray(a);
end
figure;imshow(a);title(‘原始灰度圖片‘);
npix?=?sum(sum(a));
%%??計算L*L大的盒子的nL?即Zij
%calculates?niL?which?is?the?number?of?pixels?in?the?ith?box?of?size?L?
%?ideas?from?boxcount.m?by?F.?Moisy?have?been?borrowed?here
width?=?rows;
p?=?log(width)/log(2);
max_boxes?=?power(rows2)/power(22);
nL?=?double(zeros(max_boxesp));?%nl每一列為每個分塊疊加的值,行為分的塊數(shù)邊長每次*2
for?g=(p-1):-1:0
????siz?=?2^(p-g);?%每個盒子像素點(diǎn)數(shù)
????sizm1?=?siz?-?1;
????index?=?log2(siz);?%為nl的列數(shù)?
????count?=?0;?%為nl的行數(shù)?count=(i-1)*每條邊盒子數(shù)+j
????for?i=1:siz:(width-siz+1)
????????for?j=1:siz:(width-siz+1)
????????????count?=?count?+?1;
????????????sums?=?sum(sum(a(i:i+sizm1j:j+sizm1)));
????????????nL(countindex)?=?sums;
????????end
????end
end
%%?計算橫坐標(biāo)ln(epsilon)即logl
epsilon?=?zeros(p-11);?%eps的橫坐標(biāo)
for?l=1:p-1
????epsilon(l)=power(2l)/width;
end
logl=log(epsilon);
%%?規(guī)范化質(zhì)量,像素點(diǎn)數(shù)除以總像素點(diǎn)數(shù),即Pij
%normalized?masses
pL?=?double(zeros(max_boxesp));?%pL即pij
for?l=1:p?%l=1時分成2*2的盒子
????nboxes?=?power(rows2)/power(power(2l)2);?%所有的盒子數(shù)
????norm?=?sum(nL(1:nboxesl));
????
????for?i=1:nboxes?
????????pL(il)?=?nL(il)/norm;
????end
end
%%?計算繪圖所用所用參數(shù)
%falpha
評論
共有 條評論