%% Vector to 3D Matrix containing N images % The function provides convertion from a Vector containing N grayscale % [0, 255] layers pictures of square size ImgSz*ImgSz [px] in a 3D Matrix % containing N layers, each one of them will contain a single picture. % % Inputs: % - imgSz Size of the single squared picture % - N Total Number of pictures % - Xset Input Vector % % Outputs: % - Xmat 3D Matrix containing the pictures %% %% Filling the Matrix % The for cycles loop over the Vector Xset: the outer cycle runs over the N pictures, % the inner cycle copies a row of each picture to the current one. %% function Xmat = Vector2PictureMatrix(imgSz, N, Xset) Xmat = zeros(imgSz,imgSz, N,'uint8'); for ii=1:N for jj=1:imgSz Xmat(jj,:,ii)=Xset((ii-1)*imgSz^2+(jj-1)*imgSz+1:(ii-1)*imgSz^2+jj*imgSz); end end end