function [t] = statxture(I, scale)
%STATXURE Compute statistical measure of texture in an image.
%T = STATXURE (F, SCALE) computes six measure of texture from an
%image (reagion) F. Parameter SCALE is a 6-dim row vector whose
%elements multiply the 6 corresponding elements of T for scaling
%purposes. if SCALE is not provided it defaults o all 1s. the
%output T is 6-by-1 vector with the following elements:
% T(1) = average gray level
% T(2) = average contrast
% T(3) = Measure of smoothness
% T(4) = Thrid moment
% T(5) = Measure of uniformity
% T(6) = Entropy
if nargin == 1
scale(1:6) = 1;
else % make sure it's a row vector
scale = scale(:)';
end
%Obtain histogram and normalize it.
p = imhist(f);
p = p./numel(f);
L = length(p);
% Compute the three moments. we need the unnormalized ones
%from function statemoments. those are in vector mu.
[v, mu] = statmoments(p,3);
%compute the six texture measure:
average gray level.
t(1) = mu(1);
%standard deviation.
t(2) = mu(2).^0.5;
%smoothness.
%first normalized the variance to [0 1] by
%dividing it by (L-1)^2.
varn = mu(2)/(L-1)^2;
t(3) = 1 - 1/(1 + varn);
%thrid moment (normalized by (L-1)^2 also).
t(4) = mu(3)/(L-1)^2;
%uniformity.
t(5) = sum(p.^2);
%entropy.
t(6) = -sum(p.*(log2(p + eps)));
%scale the values.
t=t.*scale;
haduh...saya udah lumyan lama gak ngutak ngatik matlab...hehe
BalasHapusmnyan harus di loding dulu...
tapi paham gak??
BalasHapussaya butuh banged....
mohon bantuannya