示例#1
0


nuclei_area = 0.0
mitosis_area = 0.0
num = 0

for img in images:
    cntr = Controller(img)
    if normalized:
        img, _, __, __ = macenko(cntr)

    plt.imsave('data/imagemap' + str(num) + ".png", img)
    num += 1
    print ("making nuclei map")
    nimg, nuclei_map = nuclei_detect_pipeline(img)
    print ('created')

    print('synthesizing image through reflection')
    img2 = np.append(img, np.append(img, img, axis = 0), axis = 0)
    img3 = np.append(img2, np.append(img2, img2, axis = 1), axis = 1)
    print('synthesized -- ', img3.shape)

    def get_patches(coords, patchsize=PATCH_SIZE):
        patches = np.zeros((len(coords), patchsize, patchsize, 3))
        i = 0
        for (x, y) in coords:
            x += SIZE
            y += SIZE
            #print x, y
            #print (x - patchsize/2), (x + patchsize/2 + 1), (y - patchsize/2), (y + patchsize/2 + 1)
#generate ICPR heatmap files

import numpy as np

import matplotlib
import matplotlib.pyplot as plt
import glob, sys, os, csv
import scipy.io, scipy.misc


from nuclei_detect import nuclei_detect_pipeline

for image_file, csv_file in zip(sorted(glob.glob("icpr/train/*.bmp")), sorted(glob.glob("icpr/train/*.csv"))):
	
	print (image_file, csv_file)

	img = scipy.misc.imread(image_file)
	hmap = nuclei_detect_pipeline(img)
	
	print (hmap)

	scipy.misc.imsave(image_file[:-4] + "_image.jpg", img)
	scipy.misc.imsave(image_file[:-4] + "_heatmap.jpg", hmap)