Callum Brown
Callum Brown

Reputation: 147

Stacking images using Matplotlib.image

I need to stack two images with the same width to create a new image.

I currently have two images which are slices of the same image:

img is the name of the original image with shape (480, 640, 3)

    timestamp = img[:40, :200, :]
    variables = img[370:, :200, :]

I either want to stack these images somehow or slice the original image in such a way that I take the first 40 pixels and the last 90 pixels (as above)

Thanks in advance!

Upvotes: 1

Views: 92

Answers (1)

dzang
dzang

Reputation: 2260

You can use np.vstack:

new_img = np.vstack([img[:40, :200, :], img[370:, :200, :]])

Upvotes: 1

Related Questions