跳转到主要内容

该模块使用参考图像在图像上执行结构保持颜色归一化。

项目描述

ITKColorNormalization

Apache 2.0 License DOI Build, test, package status

概述

Insight Toolkit (ITK)模块使用参考图像对H & E图像执行结构保持颜色归一化。模块是用C++编写的,并为Python打包。

H & E (苏木精伊红)是用于对组织学图像中细胞部分进行染色的染料,通常用于医学诊断。苏木精是一种使细胞核呈紫色-蓝色染料的化合物。伊红是一种使细胞外基质和细胞质呈粉红色的化合物。然而,紫色-蓝色或粉红色的确切颜色可能会因图像而异,这可能会使图像比较变得困难。此例程通过使用参考图像(例程中提供的第二个图像)的颜色方案重新着色一个图像(例程提供的第一个图像)来解决此问题。该技术要求图像至少有3种颜色,如红、绿和蓝(RGB)。

结构保持彩色归一化是一种在Vahadane等人于2016年的论文中描述的技术,并在Ramakrishnan等人于2019年的论文中进行修改。这种技术的想法是将图像像素的颜色建模为接近纯白色,通过依赖于血红素和伊红存在量的光学吸收模型以特定的方式减少其强度。非负矩阵分解被用于每个分析的图像,以同时推导出每个像素中血红素和伊红染料的量以及每个染料的图像全局有效颜色。

在ITK中的实现通过使用类似于Arora等人于2013年的论文中提出的技术并对其进行修改的Newberg等人于2018年的论文中的技术来选择颜色吸收特性的初始估计值,从而加速非负矩阵分解。这种方法首先将问题转换为在云中一组点的凸包寻找问题,从而找到非负矩阵分解的一个良好解。

InsightSoftwareConsortium/ITKColorNormalization的主要开发者是Lee Newberg

在线尝试

我们使用Binder搭建了此技术的演示,任何人都可以尝试。点击这里:[图片链接]

Python安装

PyPI Version

ITKColorNormalization及其所有依赖项可以轻松地通过Python wheel进行安装。已为macOS、Linux和Windows以及Python 3.6、3.7、3.8和3.9的几个版本生成了wheel。如果您不希望安装到当前的Python环境中,您应该首先创建并激活一个Python虚拟环境(venv)进行工作。然后,从命令行运行以下命令:

pip install itk-spcn

启动python,导入itk包,并设置输入图像的变量名

import itk

input_image_filename = "path/to/image_to_be_normalized"
reference_image_filename = "path/to/image_to_be_used_as_color_reference"

Python中的使用

以下示例使用参考图像的颜色方案转换输入图像

Input image to be normalized

以产生输出图像

Reference image for normalization

到ITK的功能接口

Output of spcn_filter

功能,急切接口

您可以使用ITK的功能、急切接口来选择何时执行每个步骤,如下所示。处理input_imagereference_image以产生normalized_image,这是具有reference_image颜色方案的input_image。如果input_image的像素类型是RGB或RGBA,则color_index_suppressed_by_hematoxylincolor_index_suppressed_by_eosin参数是可选的。在这里,您指出血红素抑制最强的颜色通道是0(对于RGB和RGBA像素来说是红色)以及伊红抑制最强的颜色通道是1(对于RGB和RGBA像素来说是绿色);这些是RGB和RGBA像素的默认值。

input_image = itk.imread(input_image_filename)
reference_image = itk.imread(reference_image_filename)

eager_normalized_image = itk.structure_preserving_color_normalization_filter(
    input_image,
    reference_image,
    color_index_suppressed_by_hematoxylin=0,
    color_index_suppressed_by_eosin=1,
)

itk.imwrite(eager_normalized_image, output_image_filename)

ITK管道接口

或者,您可以使用ITK管道基础设施,它在调用Update()Write()之前等待执行管道。函数itk.StructurePreservingColorNormalizationFilter.New()使用其参数来确定过滤器的像素类型;实际图像在那里不使用,而是通过spcn_filter.SetInput(0, input_reader.GetOutput())调用提供。与上面一样,如果像素类型是RGB或RGBA,则调用SetColorIndexSuppressedByHematoxylinSetColorIndexSuppressedByEosin是可选的。

input_reader = itk.ImageFileReader.New(FileName=input_image_filename)
reference_reader = itk.ImageFileReader.New(FileName=reference_image_filename)

spcn_filter = itk.StructurePreservingColorNormalizationFilter.New(
    Input=input_reader.GetOutput()
)
spcn_filter.SetColorIndexSuppressedByHematoxylin(0)
spcn_filter.SetColorIndexSuppressedByEosin(1)
spcn_filter.SetInput(0, input_reader.GetOutput())
spcn_filter.SetInput(1, reference_reader.GetOutput())

output_writer = itk.ImageFileWriter.New(spcn_filter.GetOutput())
output_writer.SetInput(spcn_filter.GetOutput())
output_writer.SetFileName(output_image_filename)
output_writer.Write()

请注意,如果在不同的 input_image 上再次使用 spcn_filter,例如来自不同的读取器,

spcn_filter.SetInput(0, input_reader2.GetOutput())

reference_image 未更改,则过滤器将使用其缓存的 reference_image 分析,这可以节省大约一半的处理时间。

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解有关安装包的更多信息。

源分发

本版本没有提供源分发文件。请参阅生成分发存档的教程。

构建分发

itk_spcn-0.2.0-cp311-cp311-win_amd64.whl (692.4 kB 查看哈希值)

上传时间 CPython 3.11 Windows x86-64

itk_spcn-0.2.0-cp311-cp311-manylinux_2_28_x86_64.whl (1.7 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.28+ x86-64

itk_spcn-0.2.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.11 manylinux: glibc 2.17+ x86-64

itk_spcn-0.2.0-cp311-cp311-macosx_10_9_x86_64.whl (2.3 MB 查看哈希值)

上传时间 CPython 3.11 macOS 10.9+ x86-64

itk_spcn-0.2.0-cp310-cp310-win_amd64.whl (692.4 kB 查看哈希值)

上传时间 CPython 3.10 Windows x86-64

itk_spcn-0.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (1.7 MB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.28+ x86-64

itk_spcn-0.2.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.10 manylinux: glibc 2.17+ x86-64

itk_spcn-0.2.0-cp310-cp310-macosx_10_9_x86_64.whl (2.3 MB 查看哈希值)

上传时间 CPython 3.10 macOS 10.9+ x86-64

itk_spcn-0.2.0-cp39-cp39-win_amd64.whl (692.9 kB 查看哈希值)

上传时间 CPython 3.9 Windows x86-64

itk_spcn-0.2.0-cp39-cp39-manylinux_2_28_x86_64.whl (1.7 MB 查看哈希值)

上传时间 CPython 3.9 manylinux: glibc 2.28+ x86-64

itk_spcn-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.9 manylinux: glibc 2.17+ x86-64

itk_spcn-0.2.0-cp39-cp39-macosx_10_9_x86_64.whl (2.3 MB 查看哈希值)

上传时间 CPython 3.9 macOS 10.9+ x86-64

itk_spcn-0.2.0-cp38-cp38-win_amd64.whl (718.1 kB 查看哈希值)

上传时间 CPython 3.8 Windows x86-64

itk_spcn-0.2.0-cp38-cp38-manylinux_2_28_x86_64.whl (1.7 MB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.28+ x86-64

itk_spcn-0.2.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传时间 CPython 3.8 manylinux: glibc 2.17+ x86-64

itk_spcn-0.2.0-cp38-cp38-macosx_10_9_x86_64.whl (2.3 MB 查看哈希值)

上传时间 CPython 3.8 macOS 10.9+ x86-64

itk_spcn-0.2.0-cp37-cp37m-win_amd64.whl (717.2 kB 查看哈希值)

上传时间 CPython 3.7m Windows x86-64

itk_spcn-0.2.0-cp37-cp37m-manylinux_2_28_x86_64.whl (1.7 MB 查看哈希值)

上传于 CPython 3.7m manylinux: glibc 2.28+ x86-64

itk_spcn-0.2.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB 查看哈希值)

上传于 CPython 3.7m manylinux: glibc 2.17+ x86-64

itk_spcn-0.2.0-cp37-cp37m-macosx_10_9_x86_64.whl (2.3 MB 查看哈希值)

上传于 CPython 3.7m macOS 10.9+ x86-64

支持者

AWS AWS 云计算和安全赞助商 Datadog Datadog 监控 Fastly Fastly CDN Google Google 下载分析 Microsoft Microsoft PSF 赞助商 Pingdom Pingdom 监控 Sentry Sentry 错误记录 StatusPage StatusPage 状态页面