求检测图像中平行线(或直线)的代码,检测出来后将平行线或者直线(最长的直线)标记为红色线条
注:图像一般为二值图像,用hough变换检测直线或平行线,
需要delphi代码!
帮忙!!

解决方案 »

  1.   

    假设你的线都是水平线而且背景是白色线条是黑色,那么这个函数可以帮你找到最长线条所在的X坐标,其余可以参照这个函数去做了
    function MaxLine(BMP: TBitmap): Integer;
    var
      x, y, tempMax, Max, tempInt: Integer;
    begin
      for y := 0 to BMP.Height do
      begin
        tempMax := 0;
        Max := 0;
        for x := 0 to BMP.Width do
        begin
          if BMP.Canvas.Pixels[x,y] = clBlack then Inc(tempMax);
          if (BMP.Canvas.Pixels[x,y] = clWhite) and (tempMax > Max) then
          begin
            Max := tempMax;
            Result := x;
            tempMax := 0;
          end;//if
        end;//for x
      end;//for y
    end;