三维高斯模型 opencv实现
- OnProbabilityModel()
- {
- int i;
- for(int x=0;x<workImg->height;x++)
- {
- for(int y=0;y<workImg->width;y++)
- {
- //double cur[3];
- CvMat* cur=cvCreateMat(3,1,CV_32F);
- for(i=0;i<3;i++){
- double tt=((uchar*)(workImg->imageData+x*workImg->widthStep))[y*3+i];
- cvmSet(cur,i,0,tt);
- }
- CvMat dst=cvRGB2YCbCr(cur);
- if(CalProbability(WHITE,&dst)<0.1&&CalProbability(YELLOW,&dst)<0.1)
- for (i=0;i<3;i++)
- ((uchar*)(workImg->imageData+x*workImg->widthStep))[y*3+i]=0;
- }
- }
- Invalidate();
- }
- double CalProbability(int classid,CvMat* cur)
- {
- /************************************************************************/
- /* function:
- 一个像素点cur[3]={r,g,b}; 它属于classid色类的概率
- */
- /************************************************************************/
- double temp,t1;
- CvMat inv_w,inv_y;
- cvInitMatHeader(&inv_w,3,3,CV_32F,Inv_white);
- cvInitMatHeader(&inv_y,3,3,CV_32F,Inv_yellow);
- CvMat* tmp=cvCreateMat(1,3,CV_32F);
- CvMat* tmp1=cvCreateMat(1,3,CV_32F);
- CvMat* res=cvCreateMat(1,1,CV_32F);
- //double tmp[3][3],tmp1[3][3];
- //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- temp=1/pow(2*PI,3/2)/sqrt(norm[classid]);
- //cvmGetMat()
- for (i=0;i<3;i++) {
- double x=cvmGet(cur,i,0);
- x-=mean_ycbcr[classid][i];
- if(x<0)
- x=0;
- cvmSet(cur,i,0,x);
- }
- double c1=cvmGet(cur,0,0);
- double c2=cvmGet(cur,1,0);
- double c3=cvmGet(cur,2,0);
- cvTranspose(cur,tmp);//转置
- if(classid==WHITE)
- cvmMul(tmp,&inv_w,tmp1);
- else if(classid==YELLOW)
- cvmMul(tmp,&inv_y,tmp1);
- cvmMul(tmp1,cur,res);
- //t1=cvNorm(tmp,0,CV_L1,0);
- t1=cvmGet(res,0,0);
- t1*=(-0.5);
- temp*=pow(Ezhishu,t1);
- return temp;
- }
from: http://blog.csdn.net/abcjennifer/article/details/7392373
三维高斯模型 opencv实现的更多相关文章
- Opencv混合高斯模型前景分离
#include "stdio.h" #include "string.h" #include "iostream" #include &q ...
- 混合高斯模型:opencv中MOG2的代码结构梳理
/* 头文件:OurGaussmix2.h */ #include "opencv2/core/core.hpp" #include <list> #include&q ...
- OpenCV混合高斯模型函数注释说明
OpenCV混合高斯模型函数注释说明 一.cvaux.h #define CV_BGFG_MOG_MAX_NGAUSSIANS 500 //高斯背景检测算法的默认参数设置 #define CV_BGF ...
- [zz] 混合高斯模型 Gaussian Mixture Model
聚类(1)——混合高斯模型 Gaussian Mixture Model http://blog.csdn.net/jwh_bupt/article/details/7663885 聚类系列: 聚类( ...
- 运动检测(前景检测)之(二)混合高斯模型GMM
运动检测(前景检测)之(二)混合高斯模型GMM zouxy09@qq.com http://blog.csdn.net/zouxy09 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新 ...
- [转]运动检测(前景检测)之(二)混合高斯模型GMM
转自:http://blog.csdn.net/zouxy09/article/details/9622401 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新的方法和思路.个人了解的 ...
- PRML读书会第九章 Mixture Models and EM(Kmeans,混合高斯模型,Expectation Maximization)
主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:10:56 今天的主要内容有k-means.混合高斯模型. EM算法.对于k-me ...
- 混合高斯模型(GMM)推导及实现
作者:桂. 时间:2017-03-20 06:20:54 链接:http://www.cnblogs.com/xingshansi/p/6584555.html 声明:欢迎被转载,不过记得注明出处哦 ...
- 混合高斯模型(Mixtures of Gaussians)和EM算法
这篇讨论使用期望最大化算法(Expectation-Maximization)来进行密度估计(density estimation). 与k-means一样,给定的训练样本是,我们将隐含类别标签用表示 ...
随机推荐
- [深入浅出WP8.1(Runtime)]网络编程之HttpClient类
12.2 网络编程之HttpClient类 除了可以使用HttpWebRequest类来实现HTTP网络请求之外,我们还可以使用HttpClient类来实现.对于基本的请求操作,HttpClient类 ...
- 五、点数器《苹果iOS实例编程入门教程》
该app为应用的功能为一个简单的数数程序 现版本 SDK 8.4 Xcode 运行Xcode 选择 Create a new Xcode project ->Single View Applic ...
- Hibernate学习笔记1
xml文件[封装]写SQL语句<class class='com.briup.user',table='s_emp'> <property name='id' column='id' ...
- linux文件创建、查看、编辑命令
一.创建文件命令 1.touch命令 linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件.touch [-acm][-r ref ...
- nginx和tomcat实现反向代理、负载均衡和session共享
这类的文章很多,nginx和tomcat实现反向代理.负载均衡实现很容易,可以参照http://blog.csdn.net/liuzhigang1237/article/details/8880752 ...
- 【android studio】android studio使用过程中,搜集的一些问题
1.[知乎]在Android Studio中如何将依赖的jar包放在SDK的android.jar前? 在编译原生Contacts应用时需用到非公开的API,需要引入framework等jar包,但在 ...
- github提交失败并报错java.io.IOException: Authentication failed:
一.概述 我最近在写一个android的项目. 软件:android studio.Android studio VCS integration(插件) Android studio VCS inte ...
- thinkphp上传至服务器后模板无法解析原因
前几日做好的响应式静态页面上传至虚拟空间,打开网址地址出现: 模板不存在:./app/Home/View/Index/index.html 错误位置 FILE: /home/u333385714/pu ...
- 好看的css3按钮和文本框
.button{ width: 80px; line-height: 25px; text-align: center; ; color: #fff; text-shadow:1px 1px 1px ...
- HDU5831
Rikka with Parenthesis II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Jav ...