function verclasse(p,W,X,c,T,cT)

%
% Display the region of activation of a single layer morphological perceptrons
%
% M. E. Valle, November 18, 2005
%
% This code comes with no guarantee or warranty of any kind.
%
% function verclasse(p,W,X,c,T,cT)
%
% Input: p = response of the dendrites.
%        W = sinpatic weight matrix.
%        X = Training matrix. Each column is a point, i.e. X = [X1,X2,...,Xp].
%        c = Training class vector. Each componente represents the class of
%            the training set matrix, i.e. ci is the class of Xi.
%        T = Test matrix.
%       cT = Test class vector.
%

c1=find(c);
c2=find(1-c);
if nargin>4
    cT1=find(cT);
    cT2=find(1-cT);
    Min=min([X,T],[],2);
    Max=max([X,T],[],2);
else
    Min=min(X,[],2);
    Max=max(X,[],2);
end

figure(1);
clf;
hold on
for k=1:size(W,2)
    alpha(1)=max(-W(1,k,1),Min(1));
    alpha(2)=max(-W(1,k,1),Min(1));
    alpha(3)=min(-W(1,k,2),Max(1));
    alpha(4)=min(-W(1,k,2),Max(1));
    
    beta(1)=max(-W(2,k,1),Min(2));
    beta(2)=min(-W(2,k,2),Max(2));
    beta(3)=min(-W(2,k,2),Max(2));
    beta(4)=max(-W(2,k,1),Min(2));
    
    if p(k)==1
        fill(alpha,beta,'c','LineStyle','none');
    else
        fill(alpha,beta,'w','LineStyle','none');
    end
    if nargin<5
        plot(X(1,c1),X(2,c1),'*b',X(1,c2),X(2,c2),'xr','MarkerSize',12);
    else
        plot(X(1,c1),X(2,c1),'*b',X(1,c2),X(2,c2),'xr',T(1,cT1),T(2,cT1),'ob',T(1,cT2),T(2,cT2),'sr');
    end
    %if k<=10
    %    pause(2)
    %end
end
hold off
