I currently have a 4D matrix of images in the form height x width x RGB x imageNumber in which I would like to index with a 2D array without using a for loop. The 2D array is in the format of height x width with the values being the image number to index.
I've got it working with A for loop but due to speed is there a way to do it without looping? I've tried resizing the matrix and index array but no luck so far.
Here is the for loop I've got working (albeit slowly on large images):
for height = 1:h
for width = 1:w
imageIndex = index(height, width);
imageOutput(height, width, :) = matrix4D(height, width, :, imageIndex);
end
end
where h and w are the height and width dimensions of the images.
Thank you!