【发布时间】:2020-11-06 17:10:07
【问题描述】:
我正在尝试帮助一位使用非常古老的比色技术来测量细胞死亡的同事。为了简化问题,这里有一张示意图:
这被称为 96 孔板。我需要找到所有的井并返回每个井的 RGB 值。粉红色表示所有细胞都活着,蓝色表示没有细胞活着。他们有一个计算公式。现在我一直在处理这张图片,到目前为止我可以用这段代码检测所有的井:
import cv2
import numpy as np
# Read image.
img = cv2.imread('images/placaTeoricaCompleta_result.jpg')
# Convert to grayscale.
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Blur using 3 * 3 kernel.
gray_blurred = cv2.blur(gray, (3, 3))
# Apply Hough transform on the blurred image.
detected_circles = cv2.HoughCircles(gray_blurred,
cv2.HOUGH_GRADIENT, 1.2, 20, param1 = 50,
param2 = 30, minRadius = 30, maxRadius = 50)
# Draw circles that are detected.
if detected_circles is not None:
# Convert the circle parameters a, b and r to integers.
detected_circles = np.uint16(np.around(detected_circles))
for pt in detected_circles[0, :]:
a, b, r = pt[0], pt[1], pt[2]
# Draw the circumference of the circle.
cv2.circle(img, (a, b), r, (0, 255, 0), 2)
# Draw a small circle (of radius 1) to show the center.
cv2.circle(img, (a, b), 1, (0, 0, 255), 3)
cv2.imshow("Detected Circle", img)
cv2.waitKey(0)
但我找不到返回每个孔的 RGB 值的方法。
真实的图像看起来像这样:
如何返回每个圆圈的 RGB 值?这最好是从 A 到 H 和从 1 到 12 的顺序,或者将 RGB 值写在圆圈中。
【问题讨论】:
-
你有每个圆圈的质心,你可以平均质心处和附近的 RGB 值,以获得对颜色的良好测量。
-
我会推荐一个不同的色彩空间,因为数字图像中物体颜色的 R、G 和 B 分量都与击中物体的光量相关,因此彼此相关,根据这些组件的图像描述使物体识别变得困难。色调/亮度/色度或色调/亮度/饱和度方面的描述通常更相关。这是当您想要检测数字图像中的颜色时,例如您发布的第二张图像
标签: python opencv image-processing