Prominent lines not detected by the Hough transform

After starting the Canny edge detector in the image, I get clear lines. But the Hough line function seems to be missing on fairly noticeable lines when run on the edgemap Canny image. I keep only vertical and horizontal lines of Hough (tolerance of 15 degrees). Many extra lines are drawing closer, but clearly visible lines bounding the rectangles are not collected.

Here's a snippet:

cvCanny( img, canny, 0, 100, 3 ); lines = cvHoughLines2( canny, storage, CV_HOUGH_PROBABILISTIC, 1, CV_PI/180, 35, 20, 10 ); 

The main intention is to discover the rectangular rectangles that indicate the nodes of the linked list. However, the squares.c sample program only detects perfect rectangles, but if the arrow does not touch the border of the rectangle.

Could you explain some changes in the function of the Hough line that will help me get the hough lines that correspond to the clearly visible lines in the Canny edge image?

hough

+6
source share
3 answers

(Added: preprocessing step proposed by shernshiou .)

Pretreatment Steps:

  • Image threshold
  • Use connected component
  • From the results of connected components, detect and delete small objects - sets of four digits below and in the middle of each window.

(Note: The threshold step is simply the preprocessing step required by the connected component.)


If you want to detect only perfectly horizontal and vertical lines, my suggestion is to reinforce the horizontal and vertical edges (through convolution) before the Hough transform.

This will cause the true lines to be more β€œpeak” in the Hough projection and increase the likelihood that the line will be raised by OpenCV.

Stages:

  • Compute Canny edge image from input
  • Apply horizontal Sobel filtering on Canny edge image
  • Apply Hough line detection on a horizontal zoom image.
  • Apply vertical Sobel filtering on the Canny edge image. (Note: use step 1, not step 2)
  • Apply Hough line detection on a vertical zoom image.
  • Combine horizontal and vertical lines and present the result.
+9
source

Have you read the documentation you made?

I have several options for you:

  • The lines that you skip (most noticeably, the leftmost vertical line in the rightmost window in the image) are quite short. Try lowering the threshold (5th input variable cvHoughLines2). This threshold is simply the number of pixels that should lie on the line. From the image, I would suggest that the lines you skip are indeed less than 35 pixels.
  • The 6th input variable indicates the minimum string length. I assume this is in pixels, so with the 5th parameter you need 35 pixels per line, but you are looking for lines of 20 pixels or longer. The way you set this variable does not work. Lower the fifth variable, raise it if you find many unnecessary short lines.
  • Omit the 7th parameter to prevent large spaces in your lines. This will eliminate some oblique lines.

In short, try again with different values ​​for parameters 5.6 and 7.

I will try a slightly lower value for parameters 5 and 7 and a similar or slightly higher value for 6. Because of 2 above 5, there must always be less than or equal to 6 in order to have an effect. 7 should at least equal the difference between 5 and 6 if 5 is less.

+6
source

Usually people do not use the hough line right out of the box. Common practice involves pre-processing the image (e.g., changing the brightness, changing the color, sharpness of the image ...).

+1
source

Source: https://habr.com/ru/post/891700/


All Articles