【发布时间】:2019-11-29 04:13:39
【问题描述】:
我正在尝试针对一些病理图像测试我的模型。我需要将它们裁剪成小块。
这是我的裁剪代码。
def crop_to_four_with_cropSize(image, crop_sz=None):
if crop_sz == None:
crop_sz = image.shape[0] // 2
img_sz = image.shape[0]
y = 0
x = 0
h = crop_sz
w = crop_sz
image_crop_1 = image[y:y + h, x:x + w, :]
image_crop_2 = image[-h:, x:x + w, :]
image_crop_3 = image[y:y + h, -w:, :]
image_crop_4 = image[-h:, -w:, :]
return (image_crop_1, image_crop_2, image_crop_3, image_crop_4)
以下是我用来保存的方法。
def save_to_file(image, name, path='./'):
if not os.path.exists(path):
os.makedirs(path)
full_name = os.path.join(path, name)
scipy.misc.toimage(image).save(full_name)
left is orignal image,right is cropped image.
我的模型对颜色敏感,但我不知道为什么一个数字矩阵具有不同程度的亮度。
我会很感激你的指示。
【问题讨论】: