algorithm - 在单元格图像中查找椭圆
问题描述
我有组织切片的图像,我想从中分离出所有隐窝,即您可以在此图像中看到的大椭圆(在二进制阈值处理之后):
在这里,它们看起来像圆形,但在一般情况下,它们形成近似椭圆。
我尝试在 openCV 中使用 canny、findContours 或 hough_ellipse 但没有成功。
有任何想法吗?
解决方案
我没有花太长时间来完善这个答案,但它应该让你开始,然后你可以整理它。基本思想是将黄色转换为白色,将其他所有颜色转换为黑色:
#!/usr/bin/env python3
import numpy as np
import cv2
from scipy.ndimage.morphology import distance_transform_edt
# Load the image
im = cv2.imread('cells.png')
# Form binary image which is white where orginal is yellow and black everywhere else
B = np.zeros_like(im[...,0])
B = im == [38, 230, 253]
cv2.imwrite('tmp.png', (B*255).astype(np.uint8))
这让你:
现在,做一个距离变换:
# Get distance transform
distance = distance_transform_edt(B)
# Normalise for contrast and save
cv2.normalize(distance, distance, 0, 255, cv2.NORM_MINMAX)
cv2.imwrite('result.png', distance.astype(np.uint8))
所以,基本上,结果图像中的点越亮,它离细胞壁和其他东西就越远。然后,您可以在此处找到最大值并使用它们进行进一步检查。
推荐阅读
- html - 如何修复图像 src
- python - 表单模板中调整的清理功能不会将错误传递给表单
- javascript - 如何将 .NET 控制器中的数据显示到 React 视图?
- vue.js - VUEJS 检查用户是否喜欢帖子
- python - 403 禁止错误。无法访问此站点
- c# - VS 2008 MULTI LAYERS C# 项目在打开时出错
- c# - 将 NSubstitute 导入 Unity 项目
- sql - `DB2`中MS-SQL`QUOTENAME`的等价物是什么
- sql-server - 将递归存储过程包装在另一个过程中时出现“超出最大嵌套级别”错误
- php - mail() 无法发送带有 utf-8 的附件标题。带有 utf-8 内容的英文标题附件传递