检测出图像中的三角形,并且算出它的顶点位置坐标。

解决方案 »

  1.   

    如何使用hough变换
    http://nlpr-web.ia.ac.cn/english/rv/download/2002-4.pdf
    具体如何实现
    我没用过
      

  2.   

    楼上是不是当然斑竹了?gx!!SP!!!
    谁有例程?[email protected]
      

  3.   

    直线的我做过,但是代买没有了,给你说说原理吧。首先自己设一个极坐标系: p = f(O)     (这里O指角度,p 指那个距离,也就是极坐标的两个参量啦)
    根据他与直角坐标系的关系 p = x * cos(O) + y * sin(O) (式 一)1:现在程序的输入是一列坐标 (x,y)  (采样点)2:将 角度O 从 -PI/2 到 PI/2离散话,假设为180个
       将 p也从 -max到+max离散化
       自己设置一个二维矩阵 O_p【O离散话个数】【p离散化个数】3: 将 角度从最小到最大分别求 p,将O_p矩阵相应的位置 加14: 对1中每一个点(x,y)做一次3操作
    5:求 0_p矩阵中 值大于你要求的阀值的 点,于是就得到了相应的 O和p,这就是一条直线
      

  4.   

    建议看看广义的hough变换,章鱼经的书上有。
      

  5.   

    直线变换,得出直线方程
    int CPipeiDoc::HoughLine(LINE * line,int threshold)
    {
     int x,y;
     int r,theta;
     double a,b;
     int linenum = 0;   //直线的条数
     int h[800][181];    //统计r,theta的分布情况
     
     //threshold = 60;
     double tempcos[181],tempsin[181];
     int rmax,thetamax;
     double pi = 3.14159265358979323846;
     int temp=0;
     for(x=0;x<800;x++)
     for(y=0;y<181;y++)
     h[x][y] = 0; for(x=-90;x<=90;x++)    
     {
     tempcos[x+90] = cos((double)x/180.0*pi);
     tempsin[x+90] = sin((double)x/180.0*pi);
     }
     
     for(x=10;x<310;x++)
    for(y=10;y<235;y++)
    {
        if(bmpSource[x][y] ==0)
              continue;
        for(theta = -89;theta <91;theta=theta+2)
    {
        r=(int)(x* tempcos[theta+90] + y * tempsin[theta+90]);

        h[r+400][theta+90]++;
    }
    }
     
     for(int i = 0;i<8;i++)
     {
     for(x=0;x<800;x++)
     {  for(y=0;y<181;y++)
        if(temp<h[x][y])
     {
        temp = h[x][y];
        rmax = x;
        thetamax = y;
     }
     }   if(temp < threshold)  //threshold直线像素阈值,少于此值的直线将不予考虑
    break;
    rmax=rmax-400;
    thetamax=thetamax-90;
    switch(thetamax)
    {
    case 0:
         a = 350;
                     b = rmax; 
         break;  
    case 90:
         a = 0;
         b = rmax;
                     break;
    case 180:
     a = 350;
         b = - rmax;
                     break;
    case -90:    a = 0;
             b = - rmax;
     break;
    default:
         a = -tempcos[thetamax+90]/tempsin[thetamax+90];
     b = (double)rmax / tempsin[thetamax+90];
    } BOOL same = false;
    int angle1,angle2;
    angle1 =(int)(atan(a) /pi*180);
    for(int ii = 0;ii<linenum;ii++)
    {   
        angle2 = (int)(atan((line+ii)->a) /pi*180); if(  abs(angle1 - angle2) <=10 || 180-abs(angle1 - angle2) <=10)
    { same = true; break; }
    }
    if(!same)
    {
    (line+i)->a = a;
        (line+i)->b = b;
    (line+i)->c = angle1;//(int)(atan(a)/pi*180);
    (line+i)->d = temp;
         linenum ++;
    }
    else
    i--;

    temp = 0;
    h[rmax+400][thetamax+90] = 0;
    } return linenum;
    }