結構元素的擴充套件操作

2021-09-06 04:45:00 字數 1666 閱讀 1505

在介紹新的擴充套件形態學變換函式之前,介紹一組結構元素的擴充套件操作,包括結構元素的拷貝、取反和取對映操作。這些操作將在後面的形態學變換中經常出現。

函式:lhstructuringelementcopy

功能:獲得形態學結構元素的拷貝

引數:se 輸入結構元素

返回:se的拷貝,注意:在不使用時需要用cvreleasestructuringelement釋放

原始碼:iplconvkernel* lhstructuringelementcopy(iplconvkernel* se)

函式:lhstructuringelementnot

功能:獲得與當前形態學結構元素相反的結構元素

引數:se 輸入結構元素

返回:se的取反,注意:在不使用時需要用cvreleasestructuringelement釋放

原始碼:iplconvkernel* lhstructuringelementnot(iplconvkernel* se)

函式:lhstructuringelementmap

功能:獲得當前形態學結構元素的對映(反射)結構元素

引數:se 輸入結構元素

返回:se的對映(反射),注意:在不使用時需要用cvreleasestructuringelement釋放

原始碼:iplconvkernel* lhstructuringelementmap(iplconvkernel* se)

函式:lhmorpstructuringelementcard

功能:獲得當前形態學結構元素的基數

引數:se 輸入結構元素

返回:結構元素的基數

int lhstructuringelementcard(iplconvkernel* se)

return cnt;

}函式:lhstructuringelementline

功能:形態學線性結構元素的建立,常用於形態學方向分析

引數:angle len 分別為線性結構元素的角度和長度

返回:線性結構元素的指標

iplconvkernel* lhstructuringelementline(unsigned int angle, unsigned int len)

;cvpoint p2 = ;

int width = cvround(len*cos((float)angle*cv_pi/180.0));

int height = cvround(len*sin((float)angle*cv_pi/180.0));

height = height >= 1 ? height : 1;

if (width < 0)

else

cvmat *temp = cvcreatemat(height, width, cv_32sc1);

cvzero(temp);

cvline(temp, p1, p2, cvscalar(1,1,1), 1, 4, 0);

iplconvkernel* se = cvcreatestructuringelementex( width, height,

(width-1)/2, (height-1)/2,  cv_shape_custom, temp->data.i );

cvreleasemat(&temp);

return se;

}

結構元素的擴充套件操作

在介紹新的擴充套件形態學變換函式之前,介紹一組結構元素的擴充套件操作,包括結構元素的拷貝 取反和取對映操作。這些操作將在後面的形態學變換中經常出現。函式 lhstructuringelementcopy 功能 獲得形態學結構元素的拷貝 引數 se 輸入結構元素 返回 se的拷貝,注意 在不使用時需要...

結構元素IplConvKernel及操作

在opencv中,定義了乙個結構用於描述形態學中的結構元素。該結構定義如下 typedef struct iplconvkernel iplconvkernel 在這裡,對其中的變數定義做一簡單的描述 ncols,nrows 結構元素的行寬與列高 anchorx,anchory 結構元素原點 錨點 ...

檔案操作擴充套件

1.r 模式 r 寫入的位置是 當前游標所在位置,會直接改寫當前位置的值 r 可以續寫麼?可以,但是必須把游標挪到最後 r 沒有建立檔案的能力 r file open r.txt r encoding utf 8 r file.write bbb n r file.close r file1 ope...