I have a 4D array containing a set of images, and a 2D array containing the indices of the 4th dim that will allow me to create an image based on the indices of the image in the 2D index array. One way i was able to do this was very slow but used the following code.
for rows = 1:imageSize(1) for cols = 1:imageSize(2) finalImage(rows,cols,:) = imageStack(rows,cols,:,indices(rows,cols)); endend
Is there a faster way to do this in Matlab with matrix indexing?
Best Answer