Hi dear Matlab specialists,
I have an array of images, say a 2 by 3 grid of images (6 images). Each image has a resolution of 4 x 4 (for simplicity). Suppose images have shades of gray.
I uploaded the images to a 4D matrix with dimensions of 2 x 3 x 4 x 4. Now I want to create a column vector with entries
1: first pixel of the first row in image 1.1
2: second pixel of the first row in image 1.1
3: ...
16: last pixel of the last row in image 1, 1
17: first pixel of the first row in image 2, 1
...
etc. There is a template. I could successfully create this using a bundle for loops:
for imageX = 1 : resolution(2)
for imageY = 1 : resolution(1)
for pixelX = 1 : resolution(4)
for pixelY = 1 : resolution(3)
% linear index for 4D indices
row = ((imageY - 1) * resolution(2) + imageX - 1) * resolution(3) * resolution(4) + ...
(pixelY - 1) * resolution(4) + pixelX;
lightFieldVector(row) = lightField(imageY, imageX, pixelY, pixelX);
end
end
end
end
, reshape permute. , . , 2D-. , "", .
,