I have an application where I'll be repeating the following set of operations many times:
Operations:
-> Read N images (all have the same dimension (H,W))
-> Normalize each image to (0,1)
-> Store these N images in a single numpy array
-> Return the array (of shape (N, H, W))
Translating this into code, it would be something like:
def load_block(im_paths, H, W):
N = len(im_paths)
im_block = np.empty((N, H, W), dtype=np.float32)
for i, im_path in enumerate(im_paths):
image = cv2.imread(im_path, 0)
im_block[i, :, :] = (image-image.min())/(image.max()-image.min())
return im_block
So I want to speed up this process. My initial go to would be numba, however I'm not sure if it'll be of use here since I'm doing I/O ops.