Created
November 23, 2020 04:53
-
-
Save kounoike/bc28cd59583730230e10d7179c59d883 to your computer and use it in GitHub Desktop.
resize遅い件の謎
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import cv2 | |
import numpy as np | |
### VALUES | |
NUM_REPEAT = 10000 | |
### Read source image | |
# img_src = cv2.imread("lena.jpg") | |
img_src = np.zeros((1, 1, 3), dtype=np.uint8) | |
size_list = list(range(100, 1001, 20)) | |
print("resize") | |
for size in size_list: | |
time_start = time.time() | |
for i in range (NUM_REPEAT): | |
img_dst = cv2.resize(img_src, (size, size)) | |
time_end = time.time() | |
duration = (time_end - time_start) * 1000 / NUM_REPEAT | |
print(f"resize:{size}x{size}, {size*size}, {duration}") | |
print("cvtColor") | |
for size in size_list: | |
img_tmp = cv2.resize(img_src, (size, size)) | |
time_start = time.time() | |
for i in range (NUM_REPEAT): | |
img_dst = cv2.cvtColor(img_tmp, cv2.COLOR_BGR2RGB) | |
time_end = time.time() | |
duration = (time_end - time_start) * 1000 / NUM_REPEAT | |
print(f"cvtColor:{size}x{size}, {size*size}, {duration}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment