有没有HOUGH变换的C语言代码,我毕业设计急用
展开全部
Input: Original image in the form of an array: Image1[xMax][yMax]
Output: New image : Image2 [xMax][yMax] containing the detected straight lines.
Intermediate data structure: Hough [tMax][rMax] to calculate the corresponding lines.
Algorithm:
/* Fill in the Hough array*/
for (x=0; x< xMax; x++){
for (y=0 ; y< yMax ; y++){
if ( Image1[x][y] > IThresh){
for (t=0 ; t< tMax ; t++){
r = (x-xMax/2)*cos(t) +(y-yMax/2)*sin(t) ;
if (r >0) {Hough [t][r] ++;}
}
/* Process Hough array to find strong maxima */
for (t = 0; t < tMax / 2; t++)
for (r = 0; r < rMax; r++)
if (Hough[t][r] > Hthresh)
{
/* Check 5x5 neighborhood for max */
max = TRUE;
for (dt = (t - 2); dt <= (t + 2); dt++)
for (dr = (r - 2); dr <= (r + 2); dr++)
if ((dr >= 0) && (dr < rMax) && (dt >= 0) && (dt < tMax) && (Hough[dt][dr] > Hough[t][r]))
{
max = FALSE;
break;
}
/* Process Hough array to create output image array */
if (max == TRUE)
{
makeLine(r, t);
}
}
void makeLine (r,t)
{
for (x=0 ; x<xMax ; x++)
/* calculate y = r/sin (t) ?x*cotg(t) and fill in the Image2 array */
}
Output: New image : Image2 [xMax][yMax] containing the detected straight lines.
Intermediate data structure: Hough [tMax][rMax] to calculate the corresponding lines.
Algorithm:
/* Fill in the Hough array*/
for (x=0; x< xMax; x++){
for (y=0 ; y< yMax ; y++){
if ( Image1[x][y] > IThresh){
for (t=0 ; t< tMax ; t++){
r = (x-xMax/2)*cos(t) +(y-yMax/2)*sin(t) ;
if (r >0) {Hough [t][r] ++;}
}
/* Process Hough array to find strong maxima */
for (t = 0; t < tMax / 2; t++)
for (r = 0; r < rMax; r++)
if (Hough[t][r] > Hthresh)
{
/* Check 5x5 neighborhood for max */
max = TRUE;
for (dt = (t - 2); dt <= (t + 2); dt++)
for (dr = (r - 2); dr <= (r + 2); dr++)
if ((dr >= 0) && (dr < rMax) && (dt >= 0) && (dt < tMax) && (Hough[dt][dr] > Hough[t][r]))
{
max = FALSE;
break;
}
/* Process Hough array to create output image array */
if (max == TRUE)
{
makeLine(r, t);
}
}
void makeLine (r,t)
{
for (x=0 ; x<xMax ; x++)
/* calculate y = r/sin (t) ?x*cotg(t) and fill in the Image2 array */
}
参考资料: http://www.baidu.com/s?wd=HOUGH%B1%E4%BB%BB
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询