我想自动将多个硬币的图像划分为单个硬币,以便之后可以将单个硬币放入对硬币进行分类的模型中(使用Tensorflow / Keras)。
The input images look something like this
And they should look like this(很抱歉,我无法直接集成图像,因为我是StackOverflow的新手)。
我想划分输入图像,将单个硬币放入分类模型中,这样我就知道单个硬币的单个值,从而可以识别第一个输入图像的值。
我已经尝试了一个物体检测模型,但它没有检测到硬币(https://towardsdatascience.com/object-detection-with-10-lines-of-code-d6cb4d86f606)。我已经知道图像上的所有物体都是硬币,我认为有可能更简单的方法来划分图像?
先感谢您。
我会尝试类似于这个tutorial的颜色分割作为将硬币与背景分开的第一步。这是我在使用OpenCV的Python中的快速尝试:
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread("coins.jpg")
lower = np.array([0,40,5])
upper = np.array([255,255,255])
mask = cv2.inRange(hsv, lower, upper)
cv2.imshow(img)
plt.show()
plt.imshow(mask)
这使我们从输入图像中获益
到这个面具:
从这里使用blob分析和大小过滤器,您应该能够找到并分离未连接的硬币。使用active contours可以实现断开重叠区域的连接,或者因为您的目标是通过在拍摄之前移动硬币来创建训练数据集。