圖片經過帶通濾波(如DCT變換頻域係數、小波變換後的小波係數,gabor方向濾波器濾波後的係數)後,其係數服從廣義高斯分佈,廣義高斯分佈公式如下所示:
function [theta, sigma] = ggd_fit(x, theta0)
%
%[theta, sigma] = ggd_fit(x, theta0);
% 根據樣本估計單維廣義高斯分佈的參數值
% x是樣本向量
% theta0是形狀參數的初始值
% theta是迭代完成後的形狀參數值
% sigma是迭代完成後與方差有關的參數值
% 該程序是根據文獻 A globally convergent and consistent method for estimating the shape parameter of a generalized Gaussian distribution
% 編寫而成,在原作者Lingyun Zhang 基礎上修改某些部分 增強了程序的魯棒性。
% number of sample points
x = x(find(abs(x)>0.001));
n = length(x);
% estimate the shape parameter
theta = theta0;
i=1;
T(1)=theta0;
while (1)
Y1 = mean(abs(x).^theta);
Y2 = mean(abs(x).^(2*theta));
Z = Y2 / Y1 / Y1 - (theta+1);
U1 = mean(abs(x).^theta.*log(abs(x)));%Y1對theta求導
U2 = mean(abs(x).^(2*theta).*log(abs(x)));%Y2平方對theta求導
Z_dot = 2*U2/Y1/Y1 - 2*U1*Y2/Y1/Y1/Y1 - 1;%Z求導結果
theta = theta - Z/Z_dot;
i=i+1;
T(i) = theta;
if theta<0.001
theta= theta0+4;
thta0=theta;
T(i) = theta;
else if abs(T(i-1)-T(i))<10e-10
if theta>0.001
break;
else
theta= theta0+4;
thta0=theta;
T(i) = theta;
end
end
end
end;
% estimate the scale parameter
sigma = ((theta/n) * sum(abs(x).^theta)) .^ (1/theta);
利用該代碼對1000個服從均值爲0,標準差爲2的正態分佈樣本進行參數估計,得出結果爲theta=1.7871,sigma=2.6512;因爲標準高斯分佈形狀參數爲2,所以估計值1.7871合適。對於標準高斯分佈sigma是標準差的倍,所以估計出的標準差爲2.6512/1.412=1,8747,與理論值2接近,所以此次參數估計是成功的。增加樣本個數可以提高估計精度。