0

I have written a code for finding Hough Lines for transmission lines in a PCB. My code:

void MainWindow::houghline()
{
Canny( image, image_output, ui->slider_threshold_canny_1->value(), ui->slider_threshold_canny_2->value(), 3 );
cv::cvtColor(image_output,input_grey_image, CV_GRAY2BGR);
cv::vector<Vec4i> lines;
cv::HoughLinesP(image_output, lines, 1, CV_PI/180, 50, 50, 10 );
  for( size_t i = 0; i < lines.size(); i++ )
  {
    Vec4i l = lines[i];
    line( input_grey_image, Point(l[0], l[1]), Point(l[2], l[3]), Scalar(0,0,255), 3, CV_AA);
  }

QPixmap image_input = cvMatToQPixmap(input_grey_image);
ui->l_image->setPixmap(image_input);
ui->l_image->setScaledContents(true);
ui->l_image->show();

}

The output image has improper hough lines and there is also a hough line for space between a transmission line.

How to get a proper hough lines and hough lines not between the transmission lines of PCB?

Original Image: Canny edge detected Image

Pixel Level of Image: enter image description here Actually I don't want to smoothen the pixels. Just find the pixels parallel to each other and find distance between them.

Is it possible by Hough transform. Is there any other method for finding distance between the edge pixels

Marek R
  • 32,568
  • 6
  • 55
  • 140
  • 1
    Have you tried filtering by color? – bracco23 Aug 21 '17 at 15:30
  • 2
    can you show original picture. Also I see you do not want to to detect lines, but thing between them, looks like you've made unneeded step of edge detection. – Marek R Aug 21 '17 at 15:48
  • I have added the original image. How to find distance distance between the pixels. If hough transform is not possible. – Mathumathi Anblagan Aug 21 '17 at 16:48
  • When I saw [expected result](https://i.stack.imgur.com/hPYgn.png) I suspected that you are doing unnecessary edge detection. Now you have added image titled "Canny edge detected Image" and you are claiming it is original. I was right you should not do edge detection, but go back one step and on this perform `HoughLinesP`. Hough lines is trying to fit line to white pixels not to things between them!. – Marek R Aug 22 '17 at 08:02
  • What do you mean by original. Do you need to see the photograph of the image of PCB – Mathumathi Anblagan Aug 22 '17 at 09:26
  • Actually I need to find the distance between the edges. But it seems that Hough lines gives a smooth line. So Hough lines is not possible. How to get the distance between a pixel in edge and the parallel another pixel in the another edge of the transmission line – Mathumathi Anblagan Aug 22 '17 at 09:28
  • add a photograph of the image of the PCB – I.Omar Dec 16 '17 at 21:29

0 Answers0