数学基础
ljk_lqy
这个作者很懒,什么都没留下…
展开
-
根据点序列的分布来判断点是否孤僻
//根据点序列的分布来判断点是否孤僻void mark_sparse_flag(point_distributed_list &points_distributed){ int max_x,min_x,max_y,min_y; get_range(points_distributed,min_x,min_y,max_x,max_y); int bin=5;//单区间的大小原创 2012-05-09 14:08:57 · 547 阅读 · 0 评论 -
根据是否有领域点来判断点是否孤立
void mark_sparse_flag(point_distributed_list &points_distributed){ point_distributed_list::iterator pt=points_distributed.begin(); for(;pt!=points_distributed.end();pt++) { CvRect rect;原创 2012-05-09 14:09:39 · 628 阅读 · 0 评论 -
将矩形向外扩展一圈,但不超过图片的大小
void expand_rect(CvRect &rect,IplImage *img){ if (rect.x>5) {rect.x-=5;rect.width+=5;} else {rect.x=0;rect.width+=rect.x;} if (rect.y>5) {rect.y-=5;rect.height+=5;} else {rect.y=0;rect.h原创 2012-05-09 14:14:11 · 845 阅读 · 0 评论 -
由1图得到在2图中的显示,但是不画出来
void on_mouse1( int event, int x, int y, int flags, void* ustc){ CvPoint choose_pt= {-1,-1}; CvPoint response_pt= {-1,-1}; CvFont font; cvInitFont(&font, CV_FONT_HERSHEY_SIMPLEX, 0.5, 0.5, 0原创 2012-05-09 20:13:29 · 542 阅读 · 0 评论 -
判断点在直线的哪个区域
bool pt_in_positive(CvPoint pt,CvPoint input_pt1,CvPoint input_pt2){ double A,B,C; double k_t; k_t=input_pt2.x - input_pt1.x; if (k_t==0.) { A=1; B=0; C=input_pt1.x; } else原创 2012-05-10 21:11:39 · 890 阅读 · 0 评论 -
两点确定直线方程
void get_line(CvPoint2D32f pt_a,CvPoint2D32f pt_b,float &A,float &B,float &C){ if(pt_a.x!=pt_b.x) { A=(pt_b.y-pt_a.y)/(pt_b.x-pt_a.x); B=-1; C=pt_a.y-k*pt_a.x; } else { A=1;原创 2012-05-21 10:45:42 · 3237 阅读 · 0 评论 -
得到相交的四个点构成四边形
CvPoint cross_pts1[4]; CvPoint cross_pts2[4]; cross_pts1[0]=get_cross_pt(img1_choose_pts[0],img1_choose_pts[1],img1_choose_pts[2],img1_choose_pts[3]); cross_pts1[1]=get_cross_pt(img1_choose_pts[原创 2012-05-09 21:35:20 · 1622 阅读 · 0 评论 -
求数组的方差
float get_variance(float*a,int n){ float mean,sum1=0; int i; for(i=0;i<=n-1;i++) { sum1+=a[i]; } mean=sum1/n; float variance,sum2=0; for (i=0;i<=n-1;i++) { sum2+=(a[i原创 2012-05-09 14:11:14 · 2117 阅读 · 0 评论 -
pt_in_rect
bool pt_in_rect(CvPoint pt,CvRect rect){ if( pt.x>=rect.x && pt.x=rect.y && pt.y<=(rect.y+rect.height) ) return true; else return false; }原创 2012-05-09 14:06:07 · 511 阅读 · 0 评论 -
关于仿射变换
“仿射变换”是坐标点在保持共线(面)的前提下,空间中的相对距离发生变化。这就是说,坐标点的所属平面不发生变化,且原本平行的直线仍然平行,但坐标点与坐标点之间的距离可能发生与原来成比例的变化。“仿射变换”允许位移,缩放,倾斜和旋转。他不能做锥形或角度扭曲。如下图: “变换矩阵”是一个3X3的矩阵: 示例如下:a - x scale(X轴缩放)b -原创 2012-03-22 12:58:29 · 1837 阅读 · 0 评论 -
各颜色模型
HSV颜色空间HSV(hue,saturation,value)颜色空间的模型对应于圆柱坐标系中的一个圆锥形子集,圆锥的顶面对应于V=1. 它包含RGB模型中的R=1,G=1,B=1 三个面,所代表的颜色较亮。色彩H由绕V轴的旋转角给定。红色对应于 角度0° ,绿色对应于角度120°,蓝色对应于角度240°。在HSV颜色模型中,每一种颜色和它的补色相差180° 。 饱和度S取值从0到1,所转载 2012-04-10 10:24:08 · 955 阅读 · 0 评论 -
动态分配和释放一、二维数组
分配:double **a=new double *[2*numPoints]; for(int i = 0; i a[i] = new double[8]; double *b =new double[2*numPoints];释放:for(int i = 0; i { delete [8]a[i]; a[i]=NULL; }原创 2012-05-08 11:16:48 · 975 阅读 · 0 评论 -
解线性超定方程
int numPoints=10;double **a=new double *[2*numPoints]; for(int i = 0; i a[i] = new double[8]; double *b =new double[2*numPoints]; CvMat A = cvMat (2*numPoints,8, CV_64F, a); CvMat B = cv原创 2012-05-08 10:22:58 · 1232 阅读 · 0 评论 -
解超定方程求透视矩阵
float* fInit1DPointer(int num){ register int i; float* p = new float[num]; for(i=0; i<num; i++) { p[i]=0.0f; } return(p);}float** fInit2DPointer(int row,int col){ regist原创 2012-05-08 11:19:22 · 1380 阅读 · 0 评论 -
解超定方程
float* fInit1DPointer(int num){ register int i; float* p = new float[num]; for(i=0; i<num; i++) { p[i]=0.0f; } return(p);}float** fInit2DPointer(int row,int col){ regist原创 2012-05-08 14:19:29 · 1821 阅读 · 0 评论 -
求点序列的包围矩形
//针对点向量void get_range(point_distributed_list points_distributed,int &min_x,int &min_y,int &max_x,int &max_y){ min_x=min_y=max_x=max_y=0; bool min_flag=1; point_distributed_list::iterator pt=po原创 2012-05-09 14:12:22 · 716 阅读 · 0 评论 -
由两点确定的直线,得到与图边界的交点
//求一直线与图边界的交点bool get_cross_pt_with_pic(CvPoint input_pt1,CvPoint input_pt2,vector& cross_pt,IplImage* img){ if (input_pt1.x>=img->width||input_pt1.x=img->height ||input_pt2.x>=img->width||in原创 2012-05-09 20:09:52 · 1186 阅读 · 0 评论