Your code overwrites the output for each loop over i=1:lev. An equivalent code without a loop:
%seg2 = seg1(:, :, end);
What should happen with the 45 bits of the input? Do you want to store them as bits of integer values?
seg1 = randi([0,1], 3,4,5);
[row, col, lev] = size(seg1);
tmp = reshape(seg1, row*col, lev) * pow2(lev-1:-1:0).';
seg2 = reshape(tmp, row, col);