1. OnProbabilityModel()
  2. {
  3. int i;
  4. for(int x=0;x<workImg->height;x++)
  5. {
  6. for(int y=0;y<workImg->width;y++)
  7. {
  8. //double cur[3];
  9. CvMat* cur=cvCreateMat(3,1,CV_32F);
  10. for(i=0;i<3;i++){
  11. double tt=((uchar*)(workImg->imageData+x*workImg->widthStep))[y*3+i];
  12. cvmSet(cur,i,0,tt);
  13. }
  14. CvMat dst=cvRGB2YCbCr(cur);
  15. if(CalProbability(WHITE,&dst)<0.1&&CalProbability(YELLOW,&dst)<0.1)
  16. for (i=0;i<3;i++)
  17. ((uchar*)(workImg->imageData+x*workImg->widthStep))[y*3+i]=0;
  18. }
  19. }
  20. Invalidate();
  21. }
  1. double CalProbability(int classid,CvMat* cur)
  2. {
  3. /************************************************************************/
  4. /* function:
  5. 一个像素点cur[3]={r,g,b}; 它属于classid色类的概率
  6. */
  7. /************************************************************************/
  8. double temp,t1;
  9. CvMat inv_w,inv_y;
  10. cvInitMatHeader(&inv_w,3,3,CV_32F,Inv_white);
  11. cvInitMatHeader(&inv_y,3,3,CV_32F,Inv_yellow);
  12. CvMat* tmp=cvCreateMat(1,3,CV_32F);
  13. CvMat* tmp1=cvCreateMat(1,3,CV_32F);
  14. CvMat* res=cvCreateMat(1,1,CV_32F);
  15. //double tmp[3][3],tmp1[3][3];
  16. //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. temp=1/pow(2*PI,3/2)/sqrt(norm[classid]);
  18. //cvmGetMat()
  19. for (i=0;i<3;i++)    {
  20. double x=cvmGet(cur,i,0);
  21. x-=mean_ycbcr[classid][i];
  22. if(x<0)
  23. x=0;
  24. cvmSet(cur,i,0,x);
  25. }
  26. double c1=cvmGet(cur,0,0);
  27. double c2=cvmGet(cur,1,0);
  28. double c3=cvmGet(cur,2,0);
  29. cvTranspose(cur,tmp);//转置
  30. if(classid==WHITE)
  31. cvmMul(tmp,&inv_w,tmp1);
  32. else if(classid==YELLOW)
  33. cvmMul(tmp,&inv_y,tmp1);
  34. cvmMul(tmp1,cur,res);
  35. //t1=cvNorm(tmp,0,CV_L1,0);
  36. t1=cvmGet(res,0,0);
  37. t1*=(-0.5);
  38. temp*=pow(Ezhishu,t1);
  39. return temp;
  40. }

from: http://blog.csdn.net/abcjennifer/article/details/7392373

三维高斯模型 opencv实现的更多相关文章

  1. Opencv混合高斯模型前景分离

    #include "stdio.h" #include "string.h" #include "iostream" #include &q ...

  2. 混合高斯模型:opencv中MOG2的代码结构梳理

    /* 头文件:OurGaussmix2.h */ #include "opencv2/core/core.hpp" #include <list> #include&q ...

  3. OpenCV混合高斯模型函数注释说明

    OpenCV混合高斯模型函数注释说明 一.cvaux.h #define CV_BGFG_MOG_MAX_NGAUSSIANS 500 //高斯背景检测算法的默认参数设置 #define CV_BGF ...

  4. [zz] 混合高斯模型 Gaussian Mixture Model

    聚类(1)——混合高斯模型 Gaussian Mixture Model http://blog.csdn.net/jwh_bupt/article/details/7663885 聚类系列: 聚类( ...

  5. 运动检测(前景检测)之(二)混合高斯模型GMM

    运动检测(前景检测)之(二)混合高斯模型GMM zouxy09@qq.com http://blog.csdn.net/zouxy09 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新 ...

  6. [转]运动检测(前景检测)之(二)混合高斯模型GMM

    转自:http://blog.csdn.net/zouxy09/article/details/9622401 因为监控发展的需求,目前前景检测的研究还是很多的,也出现了很多新的方法和思路.个人了解的 ...

  7. PRML读书会第九章 Mixture Models and EM(Kmeans,混合高斯模型,Expectation Maximization)

    主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:10:56 今天的主要内容有k-means.混合高斯模型. EM算法.对于k-me ...

  8. 混合高斯模型(GMM)推导及实现

    作者:桂. 时间:2017-03-20  06:20:54 链接:http://www.cnblogs.com/xingshansi/p/6584555.html 声明:欢迎被转载,不过记得注明出处哦 ...

  9. 混合高斯模型(Mixtures of Gaussians)和EM算法

    这篇讨论使用期望最大化算法(Expectation-Maximization)来进行密度估计(density estimation). 与k-means一样,给定的训练样本是,我们将隐含类别标签用表示 ...

随机推荐

  1. [深入浅出WP8.1(Runtime)]网络编程之HttpClient类

    12.2 网络编程之HttpClient类 除了可以使用HttpWebRequest类来实现HTTP网络请求之外,我们还可以使用HttpClient类来实现.对于基本的请求操作,HttpClient类 ...

  2. 五、点数器《苹果iOS实例编程入门教程》

    该app为应用的功能为一个简单的数数程序 现版本 SDK 8.4 Xcode 运行Xcode 选择 Create a new Xcode project ->Single View Applic ...

  3. Hibernate学习笔记1

    xml文件[封装]写SQL语句<class class='com.briup.user',table='s_emp'> <property name='id' column='id' ...

  4. linux文件创建、查看、编辑命令

    一.创建文件命令 1.touch命令 linux的touch命令不常用,一般在使用make的时候可能会用到,用来修改文件时间戳,或者新建一个不存在的文件.touch   [-acm][-r   ref ...

  5. nginx和tomcat实现反向代理、负载均衡和session共享

    这类的文章很多,nginx和tomcat实现反向代理.负载均衡实现很容易,可以参照http://blog.csdn.net/liuzhigang1237/article/details/8880752 ...

  6. 【android studio】android studio使用过程中,搜集的一些问题

    1.[知乎]在Android Studio中如何将依赖的jar包放在SDK的android.jar前? 在编译原生Contacts应用时需用到非公开的API,需要引入framework等jar包,但在 ...

  7. github提交失败并报错java.io.IOException: Authentication failed:

    一.概述 我最近在写一个android的项目. 软件:android studio.Android studio VCS integration(插件) Android studio VCS inte ...

  8. thinkphp上传至服务器后模板无法解析原因

    前几日做好的响应式静态页面上传至虚拟空间,打开网址地址出现: 模板不存在:./app/Home/View/Index/index.html 错误位置 FILE: /home/u333385714/pu ...

  9. 好看的css3按钮和文本框

    .button{ width: 80px; line-height: 25px; text-align: center; ; color: #fff; text-shadow:1px 1px 1px ...

  10. HDU5831

    Rikka with Parenthesis II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...