function X=extract(M)

%    Extraction of non-overlapping 16x23 blocks
%    M has dimension 112 x 92.
%    ===========================================================
%    
%    function description:
%    
%    This function chops up the matrix M into subblocks of 
%    size 16x23. Subsequently it converts each block into a column
%    vector. The output is 368 x 28 a matrix consisting of these
%    column vectors.

noOfSubImages=0;
for rowblock = 1:size(M,1)/16
  for colblock =1:size(M,2)/23
    for rowOfPxls = 1:16
      for colOfPxls = 1:23
	% create block of size 16x23 out of the matrix
	block(rowOfPxls, colOfPxls) = M((rowblock - 1)*16 + ...
	    rowOfPxls, (colblock - 1)*23 + colOfPxls);
      end
    end
    noOfSubImages=noOfSubImages+1;
    X(:,noOfSubImages)=block(:);
  end
end
