I have been trying to figure out a way to segment a large already annotated image which I have the .json for into smaller images with python for the deep learning model as the image is very high in resolution and I need it to be 256x256, how can this be done?
If you read image with cv2
then you have numpy.array
and you can use indexes
img[ row_start:row_end, col_start:col_end ]
to get subimage - ie. img[0:256,0:256]
And you can repeate it in for
-loops like
all_small = []
for row in range(0, height, 256):
for col in range(0, width, 256):
small = img[ row:row+256, col:col+256 ]
all_small.append(small)