Python Forum
4D matrices - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: 4D matrices (/thread-37462.html)



4D matrices - ali1almakhmari - Jun-13-2022

Hi guys. I recently switched from MATLAB to Python and the syntax is killing me a bit. I ran across this issue here

picture[:,:,:,j] = cv2.merge([image_b, image_g, image_r])
So in summary, I have a bunch of 3D matrices (colored images that I obtained from cv2.merge) and I want to append them all together such that I have a 4D matrix called "picture" where the last index of picture controls which image I see (image 1 is picture(:,:,:,1), image 2 is picture(:,:,:,2) and so on). Based on my experience with MATLAB and Python (so far) the line above should have achieved what I wanted, where the variable "j" is an index that changes inside a for loop. However, I keep getting an error that says "list indices must be integers or slices, not tuple". I hope someone can help.