im using the following code to split the image into 20 equal parts of grid
import cv2
im = cv2.imread("apple.jpg")
im = cv2.resize(im,(1000,500))
imgwidth=im.shape[0]
imgheight=im.shape[1]
y1 = 0
M = imgwidth//20
N = imgheight//20
for x in range(0,imgwidth,M):
for y in range(0, imgheight, N):
x1 = x + M
y1 = y + N
tiles = im[x:x+M,y:y+N]
print(y1)
cv2.rectangle(im, (x, y), (x1, y1), (0, 255, 0))
cv2.imwrite("save/" + str(y)+".png",tiles)
cv2.imwrite("asas.png",im)
However i have two issues,
- The saved images are not of proper uniform size
- It only draws grid upon half of the image and not entirely.
How can I be able to sort this out?