I am using numpy to create tiles of (224*224) from my 16-bit tiff image (13777*16004). I was able to crop/slice into equal tiles of 224*224 along the rows and columns. I ran into problems while trying to create new tiles shifting by half of the tile size... For instance: A rough algorithm of what i am trying to achieve
(1:224, 1:224)
(1:224, 112:336)
( , 224:448)
The goal is to retain tile size (224*224) while shifting by half of tile size to obtain more image tiles...
Snippet of code written to perform task
row_x = img.shape[0]
column_y = img.shape[1]
tile_size_x = 224
tile_size_y = 224
range_x = mpz(ceil(row_x/tile_size_x))
range_y = mpz(ceil(column_y/tile_size_y))
for x in range(range_x, row_x):
for y in range(range_y, column_y):
x0 = x * tile_size_x
x1 = int(x0/2) + tile_size_x
y0 = y * tile_size_y
y1 = int(y0/2) + tile_size_y
z = img[x0:x1, y0:y1]
print (z.shape,z.dtype)
I keep getting wrong results, can anyone help ???