資源簡介
程序提取了很多直方圖所需要的參數特征,如均值、方差、偏度、峰度、能量和熵。

代碼片段和文件信息
function?stats?=?chip_histogram_features(?varargin?)
%?------------
%?Description:
%?------------
%??This?function?is?to?obtain?state?of?the?art?histogram?based?features
%?such?as:
%???Mean
%???Variance
%???Skewness
%???Kurtosis
%???Energy
%???Entropy
%?---------
%?History:
%?---------
%?Creation:?beta?????????Date:?09/11/2007
%----------
%?Example:
%----------
%?Stats?=?chip_histogram_features(?I‘NumLevels‘9‘G‘[]?)
%
%?-----------
%?Author:
%?-----------
%????(C)Xunkai?Wei?
%????Beijing?Aeronautical?Technology?Research?Center
%????Beijing?%9203-1210076
%
%?Parameter?checking
[I?NL?GL]?=?ParseInputs(varargin{:});
%?Scale?I?so?that?it?contains?integers?between?1?and?NL.
if?GL(2)?==?GL(1)
????SI?=?ones(size(I));
else
????slope?=?(NL-1)?/?(GL(2)?-?GL(1));
????intercept?=?1?-?(slope*(GL(1)));
????SI?=?round(imlincomb(slopeIintercept‘double‘));
end
%?Clip?values?if?user?had?a?value?that?is?outside?of?the?range?e.g.?double
%?image?=?[0?.5?2;0?1?1];?2?is?outside?of?[01].?The?order?of?the?following
%?lines?matters?in?the?event?that?NL?=?0.
SI(SI?>?NL)?=?NL;
SI(SI?1)?=?1;
%--------------------------------------------------------------------------
%?1.?Calculate?histogram?for?all?scaled?gray?level?from?1?to?NL
%--------------------------------------------------------------------------
%?Get?image?size
s?=?size(SI);
%?Generate?gray?level?vector
Gray_vector?=?1:NL;
%?intialize?parameters
Histogram?=?zeros(1NL);
%?Using?inline?function?numel?make?it?easy
for?i?=1:NL
????Histogram(i)?=?numel(find(SI==i));
end
%--------------------------------------------------------------------------
%?2.?Now?calculate?its?histogram?statistics
%--------------------------------------------------------------------------
%?Calculate?obtains?the?approximate?probability?density?of?occurrence?of?the?intensity
%?levels
Prob????????????????=?Histogram./(s(1)*s(2));
%?2.1?Mean?
Mean????????????????=?sum(Prob.*Gray_vector);
%?2.2?Variance
Variance????????????=?sum(Prob.*(Gray_vector-Mean).^2);
%?2.3?Skewness
Skewness????????????=?calculateSkewness(Gray_vectorProbMeanVariance);
%?2.4?Kurtosis
Kurtosis????????????=?calculateKurtosis(Gray_vectorProbMeanVariance);
%?2.5?Energy
Energy??????????????=?sum(Prob.*Prob);
%?2.6?Entropy
Entropy?????????????=?-sum(Prob.*log(Prob));
%-------------------------------------------------------------------------
%?3.?Insert?all?features?and?return
%--------------------------------------------------------------------------
stats?=[Mean?Variance?Skewness?Kurtosis??Energy??Entropy];
%?End?of?funtion
%--------------------------------------------------------------------------
%?Utility?functions
%--------------------------------------------------------------------------
function?Skewness?=?calculateSkewness(Gray_vectorProbMeanVariance)
%?Calculate?Skewness
term1????=?Prob.*(Gray_vector-Mean).^3;
term2????=?sqrt(Variance);
Skewness?=?term2^(-3)*sum(term1);
function?Kurtosis?=?calculateKurtosis(Gray_vectorProbMe
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????5427??2008-09-16?21:24??chip_histogram_features.m
-----------?---------??----------?-----??----
?????????????????5427????????????????????1
- 上一篇:QT程序學生管理系統
- 下一篇:stm32 isp工具支持rts,cts控制復位
評論
共有 條評論