function [vecimage]=lex_order(image,dim1,dim2)

% Lexicographically order a 2D image into a 1D image-vector
for m = 1:dim1
    for n = 1:dim2
        j = n + dim1.*(m-1);
        vtemp(j,1) = image(m,n);
    end
end

vecimage = vtemp;