I am trying to load an image file in tif format and rearrange it into a long strip but preserve the horizontal order. When I have tried to use numpy reshape it just overlays the different rows onto each other or corrupts the image. Say I have an array like this
imagearray = [1,2,3,4,5,6,7,8,9,10],
[0,0,0,0,0,0,0,0,0,0],
[1,1,1,1,1,1,1,1,1,1],
[2,2,2,2,2,2,2,2,2,2]
I want to rearrange it so that it looks like this
[1,2],
[0,0],
[1,1],
[2,2],
[3,4],
[0,0],
[1,1],
[2,2]
and so on. My issue is keeping that order as I rearrange it without using any more memory as these are 3GB images using reshape or rearrange are ways that I can use less memory. I think that it is more difficult also because the image technically has shape (n,m,3) which I don't fully understand how to manipulate. this is what the output looks like from this image when it is supposed to look more similar to this
This is the basics of the file that I am using
import cv2
import matplotlib.pyplot as plt
from PIL import Image, ImageTk
Image.MAX_IMAGE_PIXELS = None
width = 4000
height = 4000
rollwidth = 1000
I = cv2.imread("image path")
print("read image")
resizedImage = cv2.resize(I,(height,width), interpolation= cv2.INTER_LANCZOS4)
print("combined done")
testimage = np.reshape(resizedImage,((np.ceil(width/rollwidth).astype(np.int64)*height),rollwidth,3), order ='C')
cv2.imwrite("save path", testimage)
print("done")
I think that this is slightly different to the duplicate flag as using the proposed steps I still can't get the needed result