当前位置: 首页 > article >正文

C++ Mean Shift算法

原理

每个样本点最终会移动到核概率密度的峰值,移动到相同峰值的样本点属于同一种颜色

关键代码

template <typename PointType> inline
typename MeanShift<PointType>::PointsVector MeanShift<PointType>::meanshift(const PointsVector &points,
                                                                            double kernel_bandwidth) const{
    const double EPSILON_SQR = _meanshift_epsilon*_meanshift_epsilon;
    std::vector<bool> stop_moving(points.size(), false);
    PointsVector shifted_points = points;
    double max_shift_distance;
    Point point_new;
    do {
        max_shift_distance = 0;
        for(int i=0; i<shifted_points.size(); i++)
        {
            if (!stop_moving[i])
            {
                shift_point(shifted_points[i], points, kernel_bandwidth, point_new); // 带宽收缩后的值
                double shift_distance_sqr = euclidean_distance_sqr(point_new, shifted_points[i]); // 取收缩后的峰值
                if(shift_distance_sqr > max_shift_distance){
                    max_shift_distance = shift_distance_sqr;
                }
                if(shift_distance_sqr <= EPSILON_SQR) {
                    stop_moving[i] = true;
                }
                shifted_points[i] = point_new;
            }
        }
    } while (max_shift_distance > EPSILON_SQR);
    return shifted_points;
}
 效果

 参考

深入剖析Mean Shift聚类算法原理-腾讯云开发者社区-腾讯云

GitHub - facontidavide/Meanshift: Implementation of MeanShift algorithm (including Qt Demo)


创作不易,小小的支持一下吧!


http://www.kler.cn/news/317219.html

相关文章:

  • Llamaindex 使用过程中的常见问题 (FAQ)
  • 云原生周刊:Artifact Hub 成为 CNCF 孵化项目|2024.9.23
  • 【深度学习】03-神经网络3-1梯度下降网络优化方法
  • 2024年信息安全企业CRM选型与应用研究报告
  • 『功能项目』3D模型动态UI显示【76】
  • MovieLife 电影生活
  • 彻底删除国际版OneDrive for Business上的数据
  • 责任链模式实现规则校验
  • 智慧交通,智能消防系统助力高铁站安全
  • Anaconda 安装
  • Directives Vue3 自定义指令
  • 平衡二叉树(AVL树):原理、常见算法及其应用
  • cccccccccccc
  • Qt_布局管理器
  • 【漏洞复现】HIKVISION 视频编码设备接入网关 showFile.php 任意文件下载漏洞
  • tomcat 配置jenkins_home 目录
  • 动态时间【JavaScript】
  • 使用【Sa-Token】实现Http Basic 认证
  • 输电线塔目标检测数据集yolo格式该数据集包括2644张输电线塔高清图像,该数据集已经过yolo格式标注,具有完整的txt标注文件和yaml配置文件。
  • 论文阅读--Planning-oriented Autonomous Driving(二)
  • C++堆(优先队列)priority_queue
  • 删除topic提示admin token
  • The NCCoE’s Automation of the CMVP
  • 【Oauth2整合gateway网关实现微服务单点登录】
  • k8s云平台部署文档
  • 【MySQL】使用C语言连接数据库
  • Http-浏览器发出⼀个请求到收到响应经历了哪些步骤?
  • 如何使用GLib的单向链表GSList
  • 【软考】cpu的功能
  • Linux环境的JDK安装