当前位置:网站首页>【科研笔记】关于使用openslide切图的下采样倍数
【科研笔记】关于使用openslide切图的下采样倍数
2022-06-22 04:39:00 【鲤鱼王的成长之路】
背景
医学图像是非常巨大的,我们将整张图称作是WSI,也就是whole slide image。在实际处理的时候我们肯定不能用这么大的图,所以我们使用的一般是一个个小patch,这些patch就是从原图中切下来的。
为了方便叙述,我们假定有一个(h, w)的大图。
level是什么
切图的时候首先就涉及到一个level的问题。如果是level 0,那么我们就直接在这个(h, w)的图片上进行切图。如果是level 1,那么我们就是在(h/downsample_factor, w/downsample_factor)这个图上切,换言之就是大图首先被缩小了。如果是level 2,那图的大小就变成了[h/(downsample_factor^2), w/(downsample_factor^2)],也就是进一步缩小。也就是说这个图在切图之前会被首先调整为[h/(downsample_factor^level), w/(downsample_factor^level)]。
好了,那么level和downsample_factor是什么关系呢?我们不妨这样来查看。读取医学图像一般使用的是openslide这个包,代码如下。
slide = openslide.open_slide(str(filename))
slide就是一个实例化之后的对象,我们去看看它的属性slide.level_downsamples。这个里面其实就是一个列表,在本示例中,这个列表是[1.0, 4.0, 16.0, …],也就是说,这就是在不同level下降采样的倍数。level=0的时候,downsample_factor是1.0,level=1的时候,downsample_factor是4.0。当然了,不同的情况下,这个列表里的数字不一定一样,要根据具体情况具体分析,并使用slide.level_downsamples去查看确认。
切图过程
先进行上一步放缩,然后去切图。我们可以设定patch的大小,比如256,这样我们切出来的图就都是256*256。如果我们要overlap,那么就要调整步长,比如不重叠的时候步长和patch一样,按照刚刚的示例,那就是256的步长。这些都搞定了之后,要看一下resize,也就是说最后我们要把patch给缩放到多大。
保存
由于图片名称里是有坐标的,所以我们必须明确这个坐标到底是什么。一般情况下,我们可以找到坐标定义的部分。
row_cords = np.arange(0, w, args.stride * downsample_factor)
col_cords = np.arange(0, h, args.stride * downsample_factor)
不难看出,坐标使用的是最初坐标,没有经过任何缩放,我们要根据自己的需要去使用适合的坐标。
边栏推荐
- Topological sorting
- Use putty to configure port mapping to realize the access of the external network to the server
- 通过ip如何免费反查域名?
- Systematic arrangement | how many children's shoes have forgotten to be done carefully before the model development (practical operation)
- Large website technology architecture | application server security defense
- Pytorch之contiguous函数
- 拦截器的具体概念
- Get the specified row content in Oracle rownum and row_ number()
- window10无法访问局域网共享文件夹
- Interaction between C language and Lua (practice 2)
猜你喜欢

Windows10 cannot access LAN shared folder

active RM机子断电后,RM HA切换正常。但是YarnUI上查看不到集群资源,application也一直处于ACCEPTED状态。

With this set of templates, it is easier to play with weekly, monthly and annual reports

cadence allegro 17. X conversion tool for downgrading to 16.6

Knowledge points used in MVC project development (mvccontrib separates asp.net MVC project)

PCM data format

System V IPC and POSIX IPC

Internet of things UWB technology scheme, intelligent UWB precise positioning, centimeter level positioning accuracy

UC San Diego | evit: using token recombination to accelerate visual transformer (iclr2022)

Digital economy Wang Ning teaches you how to correctly choose short-term investment
随机推荐
DFS of graph
中闽在线:以“积分”为纽带 共享线上渠道资源
JUC - 线程中断与线程等待、唤醒(LockSupport)
网页设计与制作期末大作业报告——动画家宫崎骏
Mongo fuzzy query, with special characters that need to be escaped, and then query
Interaction between C language and Lua (practice 3)
Importbeandefinitionregistrar registers beans with the container
Kotlin project reports an error and lacks coroutinecontext dependency
What is a forum virtual host? How to choose?
网页设计与制作期末大作业报告——小众音乐网站
Bubble sort
The beta version of move protocol is stable, and it is temporarily decided to expand the scale of the prize pool
After the active RM machine is powered off, RM ha switching is normal. However, the cluster resources cannot be viewed on the yarnui, and the application is always in the accepted state.
EcRT of EtherCAT igh source code_ slave_ config_ Understanding of dc() function.
Go 学习笔记
BFs of figure
Daily question: the difference between ArrayList and LinkedList
requests cookie更新值
Spark - Executor 初始化 && 报警都进行1次
Graph calculation on nlive:nepal's graph calculation practice