function homoflag=homogeneity(Image)
%
%   homoflag=homogeneity(Image)
%
% function used to compute the homogeneity value of image

Image=double(Image);
[s1,s2]=size(Image);

if rem(s1,4)>0
    s1=s1-rem(s1,4);
end

if rem(s2,4)>0
    s2=s2-rem(s2,4);
end

nbx = 2;            %sub-image number in range /column  
nby = 2;            %sub-image number in azimuth /row
nx = fix(s1/nbx);   %boxsize in range
ny = fix(s2/nby);   %boxsize in azimuth

% compute the power spectrum density
[power_mean,power_var]=imagett_power(Image,nbx,nby,nx,ny);

homog_arr=power_var./power_mean;
homoflag=sum(homog_arr(:))/sum(power_mean(:)); 
end

