欢迎来到天天文库
浏览记录
ID:22023242
大小:17.51 KB
页数:10页
时间:2018-10-26
《visualc++meanshift算法》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、VisualC++:MeanShift算法2010/10/2216:51说明:1.Meanshift.h中包含一个图像类CImage,这个可能每个人用的图像类都不一样,要根据你自己的图像类做相应的修改。2.分割时,是把不同区域的均值做为该区域的全部像素的值。这一点可以在程序中看到。3.窗宽的选择很重要,请根据实际情况自己选择。4.为了节约运算时间,算法的迭代过程只进行了一次。5.该类在VS2005VisualC++.net下测试通过。//Meanshift.h:interfacefortheCMeanshiftclass.///////////////
2、/////////////////////////////////////////////////////////#if!defined(AFX_MEANSHIFT_H__E6E877AA_4E4D_42A7_BE5F_7A021E6311E9__INCLUDED_)#defineAFX_MEANSHIFT_H__E6E877AA_4E4D_42A7_BE5F_7A021E6311E9__INCLUDED_#if_MSC_VER>1000#pragmaonce#endif//_MSC_VER>1000#include"Image.h"classCMea
3、nshift{public:doublecomputeweigth(CImage&ori_img,inti,intj,intx,inty,unsignedcharcurrentvalue);unsignedcharMSsmooth(CImage&ori_img,intx,inty);CMeanshift();CMeanshift(intspatial_kwidth,intrange_kwidth,charkind);virtual~CMeanshift();BOOLmeanshiftsmooth(CImage&ori_img,CImage&out_im
4、g);BOOLinitmeanshift(charkind);BOOLmeanshiftseg(CImage&image,intnthreshold);//对经过平滑之后的图像进行分割private:double*m_pspatial_weigth;double*m_prange_weigth;charm_ckind;//thetypeofthekernelfunction;either'guass"or"flat"intm_ispatial_kwidth;//spatialkernalwidthintm_irange_kwidth;//rangeke
5、rnalwidth};#endif//!defined(AFX_MEANSHIFT_H__E6E877AA_4E4D_42A7_BE5F_7A021E6311E9__INCLUDED_)//Meanshift.cpp:implementationoftheCMeanshiftclass.////////////////////////////////////////////////////////////////////////#include"stdafx.h"#include"Meanshift.h"#ifdef_DEBUG#undefTHIS_F
6、ILEstaticcharTHIS_FILE[]=__FILE__;#definenewDEBUG_NEW#endif////////////////////////////////////////////////////////////////////////Construction/Destruction//////////////////////////////////////////////////////////////////////CMeanshift::CMeanshift(){}CMeanshift::CMeanshift(intsp
7、atial_kwidth,intrange_kwidth,charkind){m_ispatial_kwidth=spatial_kwidth;m_irange_kwidth=range_kwidth;m_ckind=kind;}CMeanshift::~CMeanshift(){}BOOLCMeanshift::meanshiftsmooth(CImage&ori_img,CImage&out_img){inti,j;intimg_width=ori_img.GetWidth();intimg_height=ori_img.GetHeigth();i
8、f(!initmeanshift(m_ckind)){ returnFALSE;}if(!o
此文档下载收益归作者所有