标签:
矩阵和图像的操作
(1)cvAnd函数
其结构
void cvAnd( //将src1和src2按像素点取“位与运算” const CvArr* src1,//第一个矩阵 const CvArr* src2,//第二个矩阵 CvArr* dst,//结果矩阵 const CvArr* mask = NULL;//矩阵经行像素点与的“开关” );
#include <cv.h> #include <highgui.h> #include <stdio.h> int main(int argc, char** argv) { IplImage *src1, *src2,*src3; src1=cvLoadImage("1.jpg"); src2=cvLoadImage("3.jpg"); src3=cvLoadImage("4.jpg"); cvAnd(src1,src2,src3); cvShowImage( "測试1", src1); cvShowImage( "測试2", src2); cvShowImage( "測试3", src3); cvWaitKey(); return 0; }
void cvAndS(//使src1与value进行 位与运算 const CvArr* src1,//第一个矩阵 CvScalar value,//运算标量 CvArr* dst,//结果矩阵 const CvArr* mask = NULL;//运算开关 );
#include <cv.h> #include <highgui.h> #include <stdio.h> int main(int argc, char** argv) { IplImage *src1, *src2,*src3; src1=cvLoadImage("1.jpg"); src2=cvLoadImage("5.jpg"); CvScalar cs; cs.val[1] = 100.0; cs.val[2] = 100.0; cs.val[0] = 100.0; cs.val[3] = 100.0; cvAndS(src1,cs,src1); cvShowImage( "測试1", src1); cvShowImage( "測试2", src2); cvWaitKey(); return 0; }
CvScalar cvAvg(//求出src的平均像素值 const CvArr* src,//目标矩阵 const CvArr* mark = NULL//像素开关 );
#include <cv.h> #include <highgui.h> #include <iostream> #include <stdio.h> using namespace std; int main(int argc, char** argv) { IplImage *src1; src1=cvLoadImage("1.jpg"); CvScalar cs; cs = cvAvg(src1); cout<<cs.val[0] << endl; cout<<cs.val[1] << endl; cout<<cs.val[2] << endl; cout<<cs.val[3] << endl; getchar(); return 0; }
CvScalar cvAvg(//求像素平均值和标准差 const CvArr* arr,//目标矩阵 CvScalar* mean,//平均值 CvScalar* std_dev,//标准差 const CvArr* mark = NULL//像素开关 );
#include <cv.h> #include <highgui.h> #include <iostream> #include <stdio.h> using namespace std; int main(int argc, char** argv) { IplImage *src1; src1=cvLoadImage("1.jpg"); CvScalar cs,cs1; cvAvgSdv(src1,&cs,&cs1); cout<<"平均值:"<<endl; cout<<cs.val[0] << endl; cout<<cs.val[1] << endl; cout<<cs.val[2] << endl; cout<<cs.val[3] << endl; cout <<endl; cout <<"标准差"<<endl; cout<<cs1.val[0] << endl; cout<<cs1.val[1] << endl; cout<<cs1.val[2] << endl; cout<<cs1.val[3] << endl; getchar(); return 0; }
版权声明:本文博客原创文章,博客,未经同意,不得转载。
《学习opencv》笔记——矩阵和图像处理——cvAnd、cvAndS、cvAvg and cvAvgSdv
标签:
原文地址:http://www.cnblogs.com/bhlsheji/p/4728332.html