当前位置:网站首页>激光条纹中心提取——灰度重心法
激光条纹中心提取——灰度重心法
2022-08-09 10:55:00 【[email protected]】
菜鸡的灰度重心法
灰度重心法的概念就不用我多哔哔了,做激光中心提取的同学都知道,灰度重心法应该说是最早的一种光条中心提取算法了,顾名思义就是根据灰度值的分布求出中心,所以往往要求灰度分布成高斯分布,但是实际情况是相反的,所以这种方法就只歇着,不过有很多灰度中心法结合或者改进比较常看到。
上代码
#include <opencv2/opencv.hpp>
#include <iostream>
#include <opencv2\imgproc\types_c.h>
#include<vector>
using namespace cv;
using std::vector;
using namespace std;
// 灰度重心法
void GGM(Mat src, int i) {
Mat srcimg;
srcimg = src;
Mat grayimg;
cvtColor(srcimg, grayimg, CV_BGR2GRAY);
GaussianBlur(grayimg, grayimg, Size(0, 0), 6, 6);
//traverse each column
float x0 = 0;
for (int i = 0; i < grayimg.cols; i++) {
float sum_value = 0;
float sum_valuecoor = 0;
vector<float>current_value;
vector<float>current_coordinat;
for (int j = 0; j < grayimg.rows; j++) {
float current = grayimg.at<uchar>(j, i);
//Save the point gray value and coordinates of the threshold into the array
if (current > 30) {
current_value.push_back(current);
current_coordinat.push_back(j);
}
}
//Calculate the gray center of gravity
for (int k = 0; k < current_value.size(); k++) {
sum_valuecoor += current_value[k] * current_coordinat[k];
sum_value += current_value[k];
}
float x = sum_valuecoor / sum_value;
x0 = x;
circle(srcimg, Point(i, x), 1, Scalar(0, 0, 255), -1, 8);
current_value.clear();
current_coordinat.clear();
}
namedWindow("gscog", 0);
resizeWindow("gscog", 800, 600);
imshow("gscog", srcimg);
string save_path = ".\\RailTurnout\\center\\" + to_string(i) + ".png";
cout << save_path << endl;
imwrite(save_path, srcimg);
waitKey(10);
}
int main() {
// 相对对路径
string path = ".\\RailTurnout\\result\\*.png";
cout << path << endl;
vector<Mat> images;
vector<String> fn;
glob(path, fn, false);
cout << fn.size() << endl;
size_t count = fn.size();
cout << count << endl;
for (int i = 0; i < count; i++) {
images.push_back(imread(fn[i]));
GGM(images[i], i);
/*imshow("pic", images[i]); waitKey(10);*/
}
system("pause");
return 0;
}
贴结果
左边是没有经过深度学习去噪处理的,右边是采用深度学习去噪处理的
我建立了一个激光条纹提取的群,欢迎小伙伴加入,学习交流:点击链接加入群聊【激光条纹中心提取】先申明本人是学生,不涉及营销、宣传、推广、盈利,单纯为了学习交流,所以心怀不轨的请绕道!!!
版权声明
本文为[[email protected]]所创,转载请带上原文链接,感谢
https://blog.csdn.net/CharmsLUO/article/details/122323140
边栏推荐
- 获取指定年度所有周的工具类
- uni-app 自带的picker封装一个日期-时间选择器
- 绝了,这套RESTful API接口设计总结
- For versions corresponding to tensorflow and numpy, report FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecate
- Netscope:神经网络结构在线可视化工具
- 信息系统项目的十大管理
- jvm-类加载系统
- golang 三种指针类型具体类型的指针、unsafe.Pointer、uintptr作用
- 一键完成物联网产品注册,快速体验在线调试设备
- activemq 消息持久化
猜你喜欢
批量转换经纬度的网页实现方法
Quartz的理解
Netscope: Online visualization tool for neural network structures
PoseNet: A Convolutional Network for Real-Time 6-DOF Camera Relocalization论文阅读
Getting Started with MNIST Machine Learning
在webgis中显示矢量化后的风险防控信息
The complete grammar of CSDN's markdown editor
Netscope:神经网络结构在线可视化工具
支付宝小程序的接入
c语言函数的递归调用(汉诺塔问题,楼梯递归问题等)
随机推荐
Unix Environment Programming Chapter 14 14.4 I/O Multiplexing
focusablejs
Beauty Values
Dialogue with the DPO of a multinational consumer brand: How to start with data security compliance?See you on 8.11 Live!
unix环境编程 第十四章 14.4 I/O多路转接
prometheus接入mysqld_exporter
[Original] Usage of @PrePersist and @PreUpdate in JPA
AQS同步组件-FutureTask解析和用例
华为VRRP+MSTP联动接口检测实验案例
Netscope: Online visualization tool for neural network structures
torch.cat()函数的官方解释,详解以及例子
解决1.tensorflow运行使用CPU不使用GPU 2.tensorflow环境下的GPU版本号 3.tensorflow和cuda以及cudnn版本对应问题 4.查看cuda和cudnn版本
golang源代码阅读,sync系列-Pool
caffe ---make all editing error
15.10 the POSIX semaphore Unix environment programming chapter 15
数据存储:对dataframe类,使用to_csv()将中文数据写入csv文件
真香!肝完Alibaba这份面试通关宝典,我成功拿下今年第15个Offer
Quartz分布式实现
1005 Spell It Right (20分)
tensor.eq() tensor.item() tensor.argmax()