9
$\begingroup$

I want to find the line between color blue and color gray in the following picture:

enter image description here

More exactly, the end points of that line.

Is the Hough transform a choice? If yes how should I set up the picture before using Hough?

Any way of solving this would be helpful.

$\endgroup$

migrated from stackoverflow.com Jan 6 '12 at 1:59

This question came from our site for professional and enthusiast programmers.

  • $\begingroup$ Do an edge detection before Hough transform. It will turn that transition into a bright line with black on both sides $\endgroup$ – endolith Jan 6 '12 at 15:18
10
$\begingroup$

In general, you want an edge detector, like the Canny edge detector, for this kind of problem. The Hough transform is useful for extracting lines rather than edges.

However, in this specific case, you're better off doing something like:

imdata = imread('grayblue.jpg');
colidx = find(diff(imdata(1,:) ~= 0);

since it's such a simple image.

$\endgroup$
0
$\begingroup$

For an image this simple a convolution kernel like the following will find edges nicely:

[-1 2 - 1]

This yields a single edge pixel at each edge point. No fuss, no muss. Canny is too involved for this problem. If you want to find edge points for lines at any angle, then you can use a simple Laplacian, Laplacian of Gaussian (LoG), or Difference of Gaussian (DoG). Sobel and Prewitt are also simple but inappropriate since they yield a "double thickness" line.

There's a wicked fast implementation of Hough described here: http://www.ic.uff.br/~laffernandes/projects/kht/index.html

There are also "parameterless Hough" algorithms that are very fast, but a bit tricky to implement and debug.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy