Phụ lục
309
dy=dy-mody;
% number of non overlapping blocks required to cover
% the entire input image
nbx=size(dvalue,1)/bx;
nby=size(dvalue,2)/by;
% the output compressed image
matrice=zeros(bx,by);
% the compressed data
m_u=zeros(nbx,nby);
m_l=zeros(nbx,nby);
mat_log=logical(zeros(bx,by));
posbx=1;
for ii=1:bx:dx
posby=1;
for jj=1:by:dy
% the current block
blocco=dvalue(ii:ii+bx-1,jj:jj+by-1);
% the average gray level of the current block
m=mean(mean(blocco));
% the logical matrix correspoending to the current block
blocco_binario=(blocco>=m);
% the number of pixel (of the current block) whose gray level
% is greater than the average gray level of the current block
K=sum(sum(double(blocco_binario)));
% the average gray level of pixels whose level is GREATER than
% the block average gray level
mu=sum(sum(double(blocco_binario).*blocco))/K;
% the average gray level of pixels whose level is SMALLER than
% the block average gray level
if K==bx*by
ml=0;
else
ml=sum(sum(double(~blocco_binario).*blocco))/(bx*by-K);
end
% the COMPRESSED DATA which correspond to the input image
m_u(posbx,posby)=mu; %---> the m_u matrix
m_l(posbx,posby)=ml; %---> the m_l matrix
mat_log(ii:ii+bx-1,jj:jj+by-1)=blocco_binario;
%--->logical matrix
% the compressed image