Why you got this error?
The most likely reason is that your process crossed some limit in the amount of resources on your system that you are allowed to use. Depending on your Operating System and configuration, used too much file system space or something else. The most likely is that your program was using too much memory. Rather than risking things breaking when memory allocations started failing, the system sent a kill signal to the process that was using too much memory.
Where did you get this error?
You probably got it while loading all the images on:
img = cv2.imread(images[i]).astype(np.uint8)[:,:,::,-1].
How can you fix this?
You can try using a online Python environment or use some other computer with more RAM (Random Access Memory) and try keeping as many apps as possible closed so less memory is used.