EmguCV 一些基本操作

2022-03-12 14:18:35 字數 1409 閱讀 5528

一、先是在程式中影象的匯入,我是根據影象路徑實現,其中path是string型別,是影象路徑。

intptr img=cvinvoke.cvloadimage(path, emgu.cv.cvenum.load_image_type.cv_load_image_anycolor);

二、影象灰度化處理,先建立一幅尺寸大小為為原圖的8位影象grayimg1:

rectangle cr = cvinvoke.cvgetimageroi(img1);

int width = cr.width;

int height = cr.height;

intptr grayimg1 = cvinvoke.cvcreateimage(cr.size, emgu.cv.cvenum.ipl_depth.ipl_depth_8u, 1);

現在就能使用cvcvtcolor函式實現灰度化:

cvinvoke.cvcvtcolor(img1, grayimg1, emgu.cv.cvenum.color_conversion.cv_bgr2gray);

三、直方圖的建立,並獲取資料

int hist_size = new int[1] ;//建乙個陣列來存放直方圖資料

intptr histimg=cvinvoke.cvcreatehist(1, hist_size, emgu.cv.cvenum.hist_type.cv_hist_array, null, 1);//建立了乙個空的直方圖

cvinvoke.cvcalchist(inptr1, histimg,false,system.intptr.zero);//計算inptr1指向影象的資料,並傳入histimg中,其中intptr inptr1 = new intptr[1] 。

現在要獲取histimg中的具體資料:

for (int i = 0; i < 256; i++)

其中的dyncontourtemp為

seqdyncontourtemp1= new seq(dyncontour, null);//方便對intptr型別進行操作

seqdyncontourtemp=dyncontourtemp1;

七、對第五步檢測出的區域的座標提取,通過cvfindcontours函式的呼叫在 dyncontour中存放的是不為零區域座標的值儲存在記憶體中的首位址指標。

seqdyncontourtemp1= new seq(dyncontour, null); //方便對intptr型別進行操作

int total=contourimg.total;//contourimg包含的元素的總數

int tempx = 0;  int tempy = 0;int[,] contourarray = new int[2,total];

//獲得輪廓的座標值

for (int i = 0; i < total;i++ )

EmguCV 一些基本操作

一 先是在程式中影象的匯入,我是根據影象路徑實現,其中path是string型別,是影象路徑。intptr img cvinvoke.cvloadimage path,emgu.cv.cvenum.load image type.cv load image anycolor 二 影象灰度化處理,先建...

sublime text一些基本操作

常用的一些快捷鍵外掛程式管理常用的一些外掛程式 sublime text 的一些mac 常用的快捷鍵操作 按鍵 注釋備註 o 開啟檔案 彈出乙個選擇檔案路徑 n 新建檔案 會在sublime text 中開啟乙個新檔案 shift p 搜尋 s 儲存為了高效率的使用sublime text,安裝一些...

latex 一些基本操作

1.設定字型大小,字型,呼叫巨集包,是注釋內容 documentclass 12pt,final,journal,twocolumn,singlespaced usepackage usepackage usepackage usepackage usepackage usepackage usep...