forked from roggirg/count-ception_mbm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSplitImage.py
More file actions
29 lines (25 loc) · 998 Bytes
/
Copy pathSplitImage.py
File metadata and controls
29 lines (25 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from skimage.io import imread
import matplotlib.pyplot as plt
import math
import numpy as np
import scipy.misc
im = imread("/home/techgarage/Downloads/00500.tif")
print("Image array is: {0}".format(im))
imageShape = im.shape
imageXSize = imageShape[0]
imageYSize = imageShape[1]
print("Image X size is: {0} and Image Y size is: {1}".format(imageXSize,imageYSize))
xTargetSize = math.ceil(imageXSize/256)*256
yTargetSize = math.ceil(imageYSize/256)*256
print(xTargetSize-imageXSize)
print(yTargetSize-imageYSize)
im = np.pad(im,((0,xTargetSize-imageXSize),(0,yTargetSize-imageYSize)),'constant')
imageShape = im.shape
imageXSize = imageShape[0]
imageYSize = imageShape[1]
print("Image X size is: {0} and Image Y size is: {1}".format(imageXSize,imageYSize))
im = np.stack((im,)*3, axis=-1)
for x in range(int(xTargetSize/256)):
for y in range(int(yTargetSize/256)):
print(x,y)
scipy.misc.imsave('ImageSegments/x:{0},y:{1}.PNG'.format(x,y), im[x*256:(x+1)*256,y*256:(y+1)*256])