Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

(You probably know this, but just in case: The HoughLines function will not do canny edge detection on its own, you need to supply it with an edge image as input. It will take a grayscale input, but it will simply tread every nonzero pixel as an edge.)

If you want to do a fast hough transform for your detected blue dots, one way would be to call houghLines with a new matrix where every pixel is zero except for your detected dots. This should be very fast, since the speed of the hough transform almost solely depends on the number of edge pixels.

Unfortunately I do not think there is much more you can configure with the native houghLines function (but a basic hough transform for lines is not hard to implement)

If most of your detected edge pixels are on the line you seek, you could do a cv::lineFit

alternative ideas to speed up houghLines: - you could downscale your image first before canny edge detection and subsequent houghLines, - you could blur before canny (to decrease the number of edge pixels) - you could use higher thresholds (to decrease the number of edge pixels)

(You probably know this, but just in case: The HoughLines function will not do canny edge detection on its own, you need to supply it with an edge image as input. It will take a grayscale input, but it will simply tread every nonzero pixel as an edge.)

If you want to do a fast hough transform for your detected blue dots, one way would be to call houghLines with a new matrix where every pixel is zero except for your detected dots. This should be very fast, since the speed of the hough transform almost solely depends on the number of edge pixels.

Unfortunately I do not think there is much more you can configure with the native houghLines function (but a basic hough transform for lines is not hard to implement)

If most of your detected edge pixels are on the line you seek, you could do a cv::lineFit

alternative ideas to speed up houghLines: -

  • you could downscale your image first before canny edge detection and subsequent houghLines, -
  • you could blur before canny (to decrease the number of edge pixels) - pixels)
  • you could use higher thresholds (to decrease the number of edge pixels)

(You probably know this, but just in case: The HoughLines function will not do canny edge detection on its own, you need to supply it with an edge image as input. It will take a grayscale input, but it will simply tread every nonzero pixel as an edge.)edge. (The HoughCircles function unfortunately works totally different))

If you want to do a fast hough transform for your detected blue dots, one way would be to call houghLines with a new matrix where every pixel is zero except for your detected dots. This should be very fast, since the speed of the hough transform almost solely depends on the number of edge pixels.

Unfortunately I do not think there is much more you can configure with the native houghLines function (but a basic hough transform for lines is not hard to implement)

If most of your detected edge pixels are on the line you seek, you could do a cv::lineFit

alternative ideas to speed up houghLines:

  • you could downscale your image first before canny edge detection and subsequent houghLines,
  • you could blur before canny (to decrease the number of edge pixels)
  • you could use higher canny thresholds (to decrease the number of edge pixels)

(You probably know this, but just in case: The HoughLines function will not do canny edge detection on its own, you need to supply it with an edge image as input. It will take a grayscale input, but it will simply tread every nonzero pixel as an edge. (The HoughCircles function unfortunately works totally different))

If you want to do a fast hough transform for your detected blue dots, one way would be to call houghLines with a new matrix where every pixel is zero except for your detected dots. This should be very fast, since the speed of the hough transform almost solely depends on the number of edge pixels.

Unfortunately I do not think there is much more you can configure with the native houghLines function (but a basic hough transform for lines is not hard to implement)

If most of your detected edge pixels are on the line you seek, you could do a cv::lineFit

alternative ideas to speed up houghLines:

  • you could downscale your image first before canny edge detection and subsequent houghLines,
  • you could blur before canny (to decrease the number of edge pixels)
  • you could use higher canny thresholds (to decrease the number of edge pixels)

edit: as requested here are my suggestions for dealing with 5 megapixel images:

  • downscale the image to the point where your lines are still visible but smaller-scale features vanish. This will improve speed as well as robustness.
  • choose lower resolution for rho and theta. As low as possible, since this too improves robustness.
  • if you need higher resolution after all, use the hough transform on the downscaled image to identify the regions of interest, map these regions to your full-size image, then cut them out and do a more detailed analysis on just these edges.

Having a big but almost black image should be no problem for the hough transform. Checking whether a pixel is zero is a very fast operation, the only time-consuming work happens for edge pixels.

(You probably know this, but just in case: The HoughLines function will not do canny edge detection on its own, you need to supply it with an edge image as input. It will take a grayscale input, but it will simply tread every nonzero pixel as an edge. (The HoughCircles function unfortunately works totally different))

If you want to do a fast hough transform for your detected blue dots, one way would be to call houghLines with a new matrix where every pixel is zero except for your detected dots. This should be very fast, since the speed of the hough transform almost solely depends on the number of edge pixels.

Unfortunately I do not think there is much more you can configure with the native houghLines function (but a basic hough transform for lines is not hard to implement)

If most of your detected edge pixels are on the line you seek, you could do a cv::lineFit

alternative ideas to speed up houghLines:

  • you could downscale your image first before canny edge detection and subsequent houghLines,
  • you could blur before canny (to decrease the number of edge pixels)
  • you could use higher canny thresholds (to decrease the number of edge pixels)

edit: as requested here are my suggestions for dealing with 5 megapixel images:

  • downscale the image to the point where your lines are still visible but smaller-scale features vanish. This will improve speed as well as robustness.
  • choose lower resolution for rho and theta. As low as possible, since this too improves robustness.
  • if you need higher resolution after all, use the hough transform on the downscaled image to identify the regions of interest, map these regions to your full-size image, then cut them out and do a more detailed analysis on just these edges.

Having a big but almost black image should be no problem for the hough transform. Checking whether a pixel is zero is a very fast operation, the only time-consuming work happens for edge pixels.

pixels. The most time-consuming part might be allocating the matrix; if so, reuse the same matrix for multiple images.