吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)

%%time
NUM_SAMP=10
fig = plt.figure(figsize=(25, 16))
for jj in range(5):
    for i, (idx, row) in enumerate(df_test.sample(NUM_SAMP,random_state=SEED+jj).iterrows()):
        ax = fig.add_subplot(5, NUM_SAMP, jj * NUM_SAMP + i + 1, xticks=[], yticks=[])
        path="F:\\kaggleDataSet\\diabeticRetinopathy\\resized test 19\\"+str(row['id_code'])+".jpg"
        image = load_ben_color(path,sigmaX=50)
        plt.imshow(image, cmap='gray')
        ax.set_title('%d-%s' % (idx, row['id_code']) )

吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)_第1张图片

df_old = pd.read_csv('F:\\kaggleDataSet\\diabeticRetinopathy\\trainLabels.csv')
df_old.head()

吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)_第2张图片

NUM_SAMP=10
fig = plt.figure(figsize=(25, 16))
for class_id in sorted(train_y.unique()):
    for i, (idx, row) in enumerate(df_old.loc[df_old['level'] == class_id].sample(NUM_SAMP, random_state=SEED).iterrows()):
        ax = fig.add_subplot(5, NUM_SAMP, class_id * NUM_SAMP + i + 1, xticks=[], yticks=[])
        path="F:\\kaggleDataSet\\diabeticRetinopathy\\resized_train\\"+row['image']+".jpeg"
        image = load_ben_color(path,sigmaX=30)
        plt.imshow(image)
        ax.set_title('%d-%d-%s' % (class_id, idx, row['image']) )

吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)_第3张图片

NUM_SAMP=10
fig = plt.figure(figsize=(25, 16))
for class_id in sorted(train_y.unique()):
    for i, (idx, row) in enumerate(df_old.loc[df_old['level'] == class_id].sample(NUM_SAMP, random_state=SEED).iterrows()):
        ax = fig.add_subplot(5, NUM_SAMP, class_id * NUM_SAMP + i + 1, xticks=[], yticks=[])
        path="F:\\kaggleDataSet\\diabeticRetinopathy\\resized_train\\"+row['image']+".jpeg"
        image = cv2.imread(path)
        image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
        image = cv2.resize(image, (IMG_SIZE, IMG_SIZE))
        plt.imshow(image, cmap='gray')
        ax.set_title('%d-%d-%s' % (class_id, idx, row['image']) )

吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)_第4张图片

dpi = 80 #inch

path=f"F:\\kaggleDataSet\\diabeticRetinopathy\\resized_train\\31590_right.jpeg" # too many vessels?
image = load_ben_color(path,sigmaX=30)
# image = cv2.imread(path)
# image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# image = crop_image1(image)
# image = cv2.resize(image, (IMG_SIZE, IMG_SIZE))
# image=cv2.addWeighted ( image,4, cv2.GaussianBlur( image , (0,0) , IMG_SIZE/10) ,-4 ,128)

height, width = IMG_SIZE, IMG_SIZE
print(height, width)
SCALE=1
figsize = (width / float(dpi))/SCALE, (height / float(dpi))/SCALE
fig = plt.figure(figsize=figsize)
plt.imshow(image, cmap='gray')

吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三)_第5张图片

 

你可能感兴趣的:(吴裕雄--天生自然 PYTHON数据分析:糖尿病视网膜病变数据分析(续三))