P
P
ptvalx2020-06-05 13:47:06
Python
ptvalx, 2020-06-05 13:47:06

How to speed up the insertion of small images into the final large one?

Right now I'm just copying the tuple of colors from the small images to the large image, going through each pixel. Processes 10 fragments per second. You can use another library. I found implementations on the Internet with some hellish array designs. They gave errors and I could not figure out what was wrong.

# RGB
# 100x100 (10000) маленьких изображений размером 256x256 пикселей каждый
# финальное изображение 25600x25600
final = np.zeros((mapdata['tsize']['width'] * 256, mapdata['tsize']['height'] * 256, 3), np.uint8)

for x_tile in range(mapdata['tsize']['width']):# 0-99
    for y_tile in range(mapdata['tsize']['height']):# 0-99
        img = cv2.imread(f'{dir}/images/{x_tile}x{y_tile}.jpg')
        
        for x in range(256):
            for y in range(256):
                final[x_tile*256+x, y_tile*256+y] = img[x, y]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dr. Bacon, 2020-06-05
@ptvalx

Why work at such a low level? Read the docks by Pillow

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question