cvZero();是讓矩陣的值都為0,有初始化的作用,或者說清零~
比如說:IplImage img=cvCreateImage(cvSize(640,480),IPL_DEPTH_8U,1);%創(chuàng)建一幅圖像
cvZero(img);%相當于初始化圖片,值都為0,矩陣大小為640*480
cvShowImage("img",img);%就顯示一幅黑色,且值都為零的圖像
cvCircle(CvArr* img , CvPoint center , int radius , CvScalar color , int thickness=1 , int lineType=8 , int shift=0 )
img為圖像指針,單通道多通道都行,不需要特殊要求
center為畫圓的圓心坐標
radius為圓的半徑
color為設(shè)定圓的顏色,比如用CV_RGB(255, 0,0)設(shè)置為紅色
thickness為設(shè)置圓線條的粗細,值越大則線條越粗,為負數(shù)則是填充效果
1: #include "stdafx.h"
2: #include "opencv2/opencv.hpp"
3: #include "opencv2/opencv_modules.hpp"
4: #include "cv.h"
5: #include "cxcore.h"
6: #include "highgui.h"
7:
?
8: #define RaderImageWdith 720
9: #define RaderImageHeight 720
10:
?
11:
?
12: /*******************從文件中讀取一副圖像并在屏幕中顯示***********************/
13: int main()
14:
{
15: /*********************雷達數(shù)據(jù)處理*********************/
16:
IplImage* RaderImage = cvCreateImage(cvSize(RaderImageWdith,RaderImageHeight),IPL_DEPTH_8U,1);
17:
cvZero(RaderImage);
18: int dx = RaderImageWdith/2;
19: int dy = RaderImageHeight*3/4;
20:
cvCircle(RaderImage, cvPoint(dx,dy),3, CV_RGB(0,255,255), -1, 8,0);
21: cvShowImage( "RaderImage" ,RaderImage);
22:
23:
24:
25:
26:
27:
28:
29:
30: //定義一個字符指針,并指向圖片所在的位置
31: char *PFileName;
32: PFileName = "D:\\Pictures\\parrot.jpg" ;
33: //讀取一張圖片并載入內(nèi)存,并用一個數(shù)據(jù)結(jié)構(gòu)指針指向這張圖片
34:
IplImage *Img = cvLoadImage(PFileName);
35: if (NULL == Img) //如果讀入失敗,退出程序
36:
exit(1);
37: //創(chuàng)建一個窗體,標題為Example,自增益
38: cvNamedWindow( "Example" ,1);
39:
?
40: //用指針指向圖像的數(shù)據(jù)區(qū)頭部
41:
uchar *pchar;
42: int width = Img ->width; //讀取圖像寬度
43: int height = Img ->height; //讀取圖像高度
44: int channel = Img ->nChannels; //讀取圖像的通道數(shù)
45: int widthStep = Img ->widthStep; //讀取圖像一行像素所占的字節(jié)數(shù)
46: int i,j;
47: for (i = 0; i < height ; i++) //以下是遍歷一副圖像中的每個像素點
48:
{
49:
pchar = (uchar*)Img ->imageData + i * widthStep;
50: for (j = 0; j < width; j++)
51:
{
52:
uchar *temp = pchar + j * channel;
53: temp[0] += 10; //通道B
54: temp[1] += 10; //通道G
55: temp[2] += 10; //通道R
56:
}
57:
}
58: //在窗口中顯示這張圖片
59: cvShowImage( "Example" ,Img);
60: //暫停程序,等待用戶觸發(fā)一個按鍵
61:
cvWaitKey(0);
62: //釋放圖像所分配的內(nèi)存空間
63:
cvReleaseImage(&Img);
64: //銷毀窗口
65: cvDestroyWindow( "Example" );
66: return 0;
67:
}
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯(lián)系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
