def save_slide_cutting(file_path, save_location, level):
slide = OpenSlide(file_path)
print('==> saving slide_lv_' + str(level) + ' at ' + save_location)
x_lv_, y_lv_ = 0, 0
w_lv_, h_lv_ = slide.level_dimensions[level]
wsi_pil_lv_ = slide.read_region((0,0), level,\
(w_lv_, h_lv_))
wsi_ary_lv_ = np.array(wsi_pil_lv_)
wsi_bgr_lv_ = cv2.cvtColor(wsi_ary_lv_, cv2.COLOR_RGBA2BGR)
margin_top = int(round(h_lv_ / 12.))
margin_bottom = int(round(h_lv_ / 32.))
wsi_bgr_lv_[0:margin_top, :] = 255
wsi_bgr_lv_[h_lv_ - margin_bottom:h_lv_, :] = 255
cv2.imwrite(save_location, wsi_bgr_lv_)
# plt.subplot(1,1,1), plt.imshow(wsi_bgr_lv_)
# plt.xticks([]), plt.yticks([])
# plt.show()
评论列表
文章目录