Это мой код. Я хочу отобразить несколько изображений с помощью Matplotlib subplot
. Кодекс о разделении изображения на 4 части. Затем я хочу показать части изображения, но этот код показывает их одну за другой.
import cv2
from matplotlib import pyplot as plt
im = cv2.imread("D:\\joker.jpg")
imgheight=im.shape[0]
imgwidth=im.shape[1]
y1 = 0
M = imgheight//2
N = imgwidth//2
for y in range(0,imgheight,M):
for x in range(0, imgwidth, N):
y1 = y + M
x1 = x + N
tiles = im[y:y+M,x:x+N]
# cv2.rectangle(im, (x, y), (x1, y1), (0, 255, 0))
gg =cv2.cvtColor(tiles, cv2.COLOR_BGR2RGB)
# cv2.imwrite("save" + str(x) + '_' + str(y)+".png",tiles)
plt.imshow(gg)
plt.xticks([]), plt.yticks([])
plt.show()