我正在为试卷实施OMR系统。但在确定实心圆时会遇到问题。我已经成功地获得了这些感兴趣的灰度区域。
问题是:
我已经有大约10 GB的样本,所以机器学习或其他统计方法可能会有用。
有人知道将圆分类为实心圆的其他方法吗?
发布于 2017-04-07 01:15:20
由于这不是一个直接的问题,因此需要进行大量的调整才能使其健壮。但我想建议你一个很好的起点。您可以尝试使用它,并尝试使其工作。
import numpy as np
import cv2
image_ori = cv2.imread("circle_opt.png")
lower_bound = np.array([0, 0, 0])
upper_bound = np.array([255, 255, 195])
image = image_ori
mask = cv2.inRange(image_ori, lower_bound, upper_bound)
masked_red = cv2.bitwise_and(image, image, mask=mask)
kernel = np.ones((3,3),np.uint8)
closing = cv2.morphologyEx(mask, cv2.MORPH_OPEN, kernel)
contours = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)[0]
contours.sort(key=lambda x:cv2.boundingRect(x)[0])
print len(contours)
for c in contours:
(x,y),r = cv2.minEnclosingCircle(c)
center = (int(x),int(y))
r = int(r)
if 10 <= r <= 15:
cv2.circle(image,center,r,(0,255,0),2)
# cv2.imwrite('omr_processed.png', image_ori)
cv2.imshow("original",image_ori)
cv2.waitKey(0)我从我在你分享的图像上的代码得到的结果是

您可以将阈值应用于这些绿色圆圈斑块,然后计算非零,以获得圆圈是否被标记。您可以尝试使用lower和upper_bound来使解决方案更健壮。
希望这能有所帮助!祝你在解决问题时好运:)
https://stackoverflow.com/questions/43250212
复制相似问题