我试着检测出整个音符和半音符,但对于半音符,我似乎无法察觉,因为它是一个空洞化的圆圈。有什么方法可以探测空洞化的圆圈吗?
示例:

这是我的代码:
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
// Read image
Mat im = imread("beethoven_ode_to_joy.jpg", IMREAD_GRAYSCALE);
// Setup SimpleBlobDetector parameters.
SimpleBlobDetector::Params params;
// Change thresholds
params.minThreshold = 10;
params.maxThreshold = 200;
// Filter by Area.
params.filterByArea = true;
params.minArea = 15;
// Filter by Circularity
params.filterByCircularity = true;
params.minCircularity = 0.1;
// Filter by Convexity
params.filterByConvexity = true;
params.minConvexity = 0.01;
// Filter by Inertia
params.filterByInertia = true;
params.minInertiaRatio = 0.01;
// Storage for blobs
vector<KeyPoint> keypoints;
#if CV_MAJOR_VERSION < 3 // If you are using OpenCV 2
// Set up detector with params
SimpleBlobDetector detector(params);
// Detect blobs
detector.detect(im, keypoints);
#else
// Set up detector with params
Ptr<SimpleBlobDetector> detector = SimpleBlobDetector::create(params);
// Detect blobs
detector->detect(im, keypoints);
#endif
// Draw detected blobs as red circles.
// DrawMatchesFlags::DRAW_RICH_KEYPOINTS flag ensures
// the size of the circle corresponds to the size of blob
Mat im_with_keypoints;
drawKeypoints(im, keypoints, im_with_keypoints, Scalar(0, 0, 255), DrawMatchesFlags::DRAW_RICH_KEYPOINTS);
// Show blobs
imshow("keypoints", im_with_keypoints);
imwrite("a.jpg", im_with_keypoints);
waitKey(0);
}发布于 2015-12-30 15:23:11
我对你的建议是使用一些机器学习算法。简单地说,这是一个完整的想法:您首先需要为图像创建一个培训集。在训练中,你需要给一些东西贴上标签。其中一个标签是“空心圆”。然后你给其他音符贴上标签。我不知道有多少音符,但你可以把每个音符分别贴上标签,或者把所有不是神圣圆圈的音符都贴上标签。你也可以给背景贴上标签。然后,对培训数据进行机器学习模型的训练,然后将测试数据(模型在培训过程中没有看到的图像)输入其中,并获得准确性。您可以将数据拆分为培训和验证集进行培训。
对于标签,您可以使用本网站。
发布于 2015-12-30 20:40:35
有不同的方法可以做到这一点。这里有一个简单的例子:
结果:
一般评论:不要使用JPG格式,它增加了大量的手工艺品,这在图像处理中尤其令人讨厌,尤其是当你从事如此微小的模式检测时。
发布于 2015-12-30 17:59:19
模板匹配可能是相当普遍的,我不知道你的意思。
空洞化的圆圈就是圆圈--正如我们所说的。
所以我的第一个建议是使用hough变换(你的圆圈是否变成椭圆,你可以看到)。
因为你的圆圈只有一个大小,所以你可以成功地完成霍夫变换-阅读有关它的文章。
https://stackoverflow.com/questions/34531911
复制相似问题