線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1384
推到 Plurk!
推到 Facebook!

如何呼叫hough transform函式?

缺席
susamlin2001
一般會員


發表:15
回覆:7
積分:4
註冊:2010-06-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2010-11-11 02:39:00 IP:125.224.xxx.xxx 訂閱

[code c#]
int HTDetectLine ( XYPoint *EdgePoint, int EdgeNum, HTLine *DetectedLine, int MaxPointCount, int ThetaNum, int DistNum, int ImgHeight, int ImgWidth)
{
/*存法角及法線差[間隔長], 為求哈克參數空間可分成多少小房子用*/
float DeltaNormAngle, DeltaNormDistance ;
/*存法距之最大值和最小值用*/
float MaxNormdistance, MinNormdistance ;
/*將各邊點X,Y在投票時轉成參數空間(Theta, Dist)之值*/
float Theta , Dist;
/*用來記錄找到幾條線*/
int CountLine ;
/*作為投票時在哈克空間中某邊點(x,y)所在的小房子其第一index下, 所求出之第二index之臨 時儲存變數 */
short int TempIndex2 ;
/*二維之參數空間(累積陣列)*/
int **HSCellCount;
/*依照使用者所定大小動態配置累積陣列*/
HSCellCount=new int *[ThetaNum];
for(int i=0;i HSCellCount[i]=new int [DistNum];

/*法距最大值為sqrt(x^2 y^2)*/
MaxNormdistance=sqrt(ImgWidth*ImgWidth ImgHeight*ImgHeight);
/*法距負最大值為x軸之大小*/
MinNormdistance= -1*ImgWidth; /*法距負最大為負 x 軸*/
/*固定參數法角數目下, 其法角差為總長/個數 [總長為 pi]*/
DeltaNormAngle = M_PI/(ThetaNum -1) ;
/*固定參數法距數目下, 其法距差*/
DeltaNormDistance= (MaxNormdistance - MinNormdistance)/(DistNum -1) ;
/*二維之參數空間, HSCellCount1(i, j) 存投票數, 現設各小房子票數為 0*/
for (int i=0;i for(int j=0;j HSCellCount[i][j]=0 ;
Theta=0;
Dist=EdgePoint[0].X*cos(Theta) EdgePoint[0].Y*sin(Theta) ;
for(int i=0;i for(int j=0;j {
/*本應加最小法角, 因為 0 故不用, 求法角上各量化區間之法角為
多少*/
Theta=j*DeltaNormAngle ;
/*求某邊點在法角下其法距為多少*/
Dist=EdgePoint[i].X*cos(Theta) EdgePoint[i].Y*sin(Theta) ;
/*算所求法距屬於第幾個區間, 並且在相對應的cell投票*/
HSCellCount[j][(int)((Dist-MinNormdistance)/DeltaNormDistance)] ;
}
/*初值設目前沒有線, 現在測出之線總數為0*/
CountLine = 0 ;
/*儲存此次測線所使用的各項參數設定*/
DetectedLine->DeltaNormAngle=DeltaNormAngle;
DetectedLine->DeltaNormDistance=DeltaNormDistance;
DetectedLine->MinNormdistance=MinNormdistance;
DetectedLine->ThetaNum=ThetaNum;
DetectedLine->DistNum=DistNum;
/*求有幾個小房子內投票數大於MaxPointCount, 即在哈克空間中找到幾條線*/
for(int i=0;i for(int j=0;j /*當有一小房子投票點數夠大時, 即認定有一線存在*/
if (HSCellCount[i][j]>=MaxPointCount)
{
CountLine ;
DetectedLine->LinePoint[CountLine].I1=i;
DetectedLine->LinePoint[CountLine].I2=j;
}

for(int i=0;i delete [] HSCellCount[i];

delete[] HSCellCount;
return CountLine;
}
[/code]

請問我該怎麼呼叫這個函式?

XYPoint *EdgePoint 以及 HTLine *DetectedLine在呼叫時該輸入什麼?
系統時間:2024-04-26 5:02:14
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!