我怎样才能做这样的分割

2024-04-27 13:38:11 发布

您现在位置:Python中文网/ 问答频道 /正文

this work:Montouro等人指定了一种分割OCT图像的方法,如下所示:

Example

我想做一个类似的细分,但我不知道怎么做。这就是我所尝试的:

# load image 
img = cv2.imread('OCT.jpeg')

# define colors
color1 = (255,0,0)
color2 = (255,128,128)
color3 = (0,92,0)
color4 = (128,192,255)
color5 = (0,164,255)
color6 = (122,167,141)
color7 = (0,255,0)
color8 = (0,0,255)

# build 8 color image of size 256x1 in blocks of 32
lut = np.zeros([1, 256, 3], dtype=np.uint8)
lut[:, 0:32] = color1
lut[:, 32:64] = color2
lut[:, 64:96] = color4
lut[:, 96:128] = color5
lut[:, 128:160] = color6
lut[:, 160:192] = color7
lut[:, 192:256] = color8

# apply lut
result = cv2.LUT(img, lut)

# save result
cv2.imwrite('lut.png', lut)
cv2.imwrite('OCT_colorized.png', result)

我得到了这个结果:

my

这不是我想要的。我怎样才能重现Montuoro等人在工作中所做的事情


Tags: ofimageimgnpresultcv2octlut
3条回答

问题中引用的论文解释了一种非常详细的图像分割方法。本文对此进行了解释

从报纸上看:

... the proposed method consists of the following steps: First, image-based features are extracted from the raw OCT data and are used together with manual labels to train a base voxel classifier. The resulting probability map is then used to perform the initial surface segmentation and to extract various context-based features. Second, these features are used in conjunction with the image-based features to train another classifier. Such context-based feature extraction and additional classifier training is then iteratively repeated multiple times in auto-context loop.

如果您正在寻找类似的结果,那么您应该看看作者实现了什么,并复制它。论文中有足够的细节来构建作者的创作

冒着听起来愚蠢的风险,你可以尝试的步骤很少

首先,尝试使用颜色和分割边界。对于硬编码的示例,您使用蓝色而不是浅蓝色,等等。此外,您正在以等距数字(每32个像素值)创建色带,但不同组件的含义决定了不同的色带。例如,颜色2与您的深蓝色混合表示第一个波段太窄。利用它来探索数据。也许看看直方图,看看会跳出什么

这可能无法为您提供所显示的漂亮图像。这种分割似乎是通过更多的计算来完成的,而不仅仅是像素值。生物学很混乱。传感器乱七八糟。有一个努力,以清理这一点,迫使分割是连续的。这有时也可能是错误的来源

第一部分,选择以何种方式显示哪些像素,有时称为颜色映射,使用NumPy的ListedColormap。第二部分,学习如何分割图像以制作可呈现的水肿,通常是图像分割,可能需要一些深入的学习

在您的方法中,永远不可能正确分割图像。您可以在地面真相图像中应用代码,其中每个实例都有唯一的标签,在这种情况下,它将起作用。如果你不想使用深度学习,你可以尝试使用multi class ostu thresholding,尽管这种类型的计算机视觉算法性能会很差。如果需要手动操作labelme是可预置的,许多工具都可以在线使用。为了获得最佳可视化效果(制作任何表格或图表),您可以尝试使用深度学习(Link1Link2)或手动分段

相关问题 更多 >