openslide---常用函数

本文介绍了如何使用openslide库来读取文件,并详细探讨了获取图像原始大小的多种方法,包括切片操作和获取不同分辨率层数的细节。同时,文章还讲解了如何按层切割图像以及每层的尺寸和块数。
摘要由CSDN通过智能技术生成

1.读取文件

import openslide
from openslide.deepzoom import DeepZoomGenerator
slide = openslide.open_slide('/images/save/AI201804_R17-xxxx-CD_171-20_1M_x16335_y25644_w1024_h1024.png')
result_path = '/images/save'
print(result_path)

2.图像原始大小(获取图像原始大小有多种方法)

[w,h] = slide.level_dimensions[0]

3.切片方法

 各参数及其含义,参考官方说明:

class openslide.deepzoom.DeepZoomGenerator(osr, tile_size=a, overlap=1, limit_bounds=False)
osr – the slide object
tile_size (int) – the width and height of a single tile. For best viewer performance, tile_size + 2 * overlap should be a power of two.
overlap (int) – the number of extra pixels to add to each interior edge of a tile
limit_bounds (bool) – True to render only the non-empty slide region 
data_gen = DeepZoomGenerator(slide, tile_size=50, overlap=0, limit_bounds=False)
(实际上,只需要上方这一行代码&#
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值