openCV中的向量和图像的创建

#include <cv.h>
#include <stdio.h>
#include <highgui.h>
#include <stdlib.h>

void CreateEchelonIdentity(CvArr *Array,CvScalar Color)
{
     cvSetIdentity(Array,Color);//将数组中对角线上的元素设为1,其他置为0
}
void CreateRectangle(CvArr *Array,CvPoint point1,CvPoint point2,CvScalar color)
{
     cvRectangle(Array,point1,point2,color);//画一个矩形
}
int main()
{
     IplImage *Image1;
  IplImage *Image2;

     CvSize Size1=cvSize(320,240);
     CvSize2D32f Size2 =cvSize2D32f(640.0,480.0);

     CvScalar Scalar1=cvScalar(0,1,2,3);
     CvScalar Scalar2=cvRealScalar(10);//仅第一个成员被初始化为参数值,其余量被设置为0
     CvScalar Scalar3=cvScalarAll(20);//该向量的四个成员变量全被设置为同一个参数值
     CvScalar Scalar4=CV_RGB(255,255,3);//创建三维的颜色

     Image1=cvCreateImage(Size1,IPL_DEPTH_8U,3); //创建图像
     CreateEchelonIdentity(Image1,Scalar4);
    
  Image2=cvCreateImage(cvSize(600,600),IPL_DEPTH_8U,3);
  CvPoint point1=cvPoint(0,0);
  CvPoint point2=cvPoint(600,600);
  CvScalar scalar5=CV_RGB(255,0,240);
  CreateRectangle(Image2,point1,point2,scalar5);
     printf("The Size1 height is : %d\n",Size1.height);
     printf("The Size1 width is : %d\n\n",Size1.width);

     printf("The Size2 height is : %.1f\n",Size2.height);
     printf("The Size2 width is : %.1f\n\n",Size2.width);

     printf("The Scalar1 is: (%.1f,%.1f,%.1f,%.1f)\n",Scalar1.val[0],Scalar1.val[1],Scalar1.val[2],Scalar1.val[3]);
     printf("The Scalar2 is: (%.1f,%.1f,%.1f,%.1f)\n",Scalar2.val[0],Scalar2.val[1],Scalar2.val[2],Scalar2.val[3]);
     printf("The Scalar3 is: (%.1f,%.1f,%.1f,%.1f)\n\n",Scalar3.val[0],Scalar3.val[1],Scalar3.val[2],Scalar3.val[3]);

     printf("The Scalar4 is: (%.1f,%.1f,%.1f,%.1f)\n",Scalar4.val[0],Scalar4.val[1],Scalar4.val[2],Scalar4.val[3]);

     cvNamedWindow("Echelon Identity",1);
     cvShowImage("Echelon Identity",Image1);

  cvNamedWindow("Rectangle Identity",1);
     cvShowImage("Rectangle Identity",Image2);

     cvWaitKey(0);

  return 0;
}

你可能感兴趣的:(image,include)