function [class, mu, sigma] = classify64(I)
%CLASSIFY64 First pass classification of postal image blocks.
%   [CLASS,MU,SIGMA] = CLASSIFY64(I) performs the first pass classification of I 
%   into the categories: picture, text, background, or undetermined.  This 
%   classification is returned as the scalar CLASS with values as follows:  
%
%   1 = picture
%   2 = text
%   3 = background
%   4 = undetermined
%
%   MU is the mean value of the block and SIGMA is the standard deviation.    
%
%   I is the matrix of pixel values of a grayscale image block of size 64x64.  
%
%   See also POSTALSEG, FIRSTPASS, FEATURES

%   Author(s): K. R. Varshney
%   School of Electrical and Computer Engineering, Cornell University
%   $Date: 2002/08/15 $

% get features to enable classification by decision tree
A = features(I);

% background
if A.sigma<10
    class = 3;
% text
elseif (A.Dx>25 & A.Dy>25 & A.alpha>300) | (A.Dx>50 & A.Dy>50)
    class = 2;
% picture
elseif A.sigma>25 & (A.alpha<200 | A.gc<1e4)
    class = 1;
% undetermined
else
    class = 4;
end

mu=A.mu;
sigma=A.sigma;