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

% Unlexicographically order a 1D image-vector into a 2D image
for m = 1:dim1
    for n = 1:dim2
        i = n + dim1.*(m-1);
        temp(m,n) = vecimage(i,1);
    end
end

image = temp;