fmw42 wrote:
Just curious about your python code for creating the hough transform. I don't read code that well, but it looks like you need openCV to create the accumulator? or am I mistaken? can that be done simply in a python or shell script without openCV?
For the accumulator itself I do not need openCv per se. I simply need a 2D matrix of integers to store the accumulator values.
This could be done in pure python, but would probably be slower.
I am considering switching to the numPy library for this.
However OpenCV has a class for 2D matrices, and also methods for displaying them as images, and loading and saving them in common image formats, so this saved a lot of time
and I am using openCv for several other things like fast sobel filter and canny edge detection anyway.
(the last line "cvConvertScale(accumulator,accumulator,100000/maxacc)" is not part of the hough transform, just a quick hack. I multiplied each value with 1000000 to enhance the contrast for displaying.)
Currently I am using openCV for the following:
- reading the input image file into a 2d matrix
this could probably be done with PIL, the Python image library
possibly with the Imagemagick python interface too.
-displaying the matrixes as images, saving them as images
- canny edge detection
edge detection could be done with imagemagick, but the canny filter is really superiour for this problem.
-sobel filter
much faster than with imagemagick, but not essential
- mean, morphological grayscale open, dilate.
I am experimenting with these for noise filtering and non-maximum supression
much faster than the equivalent commands in imagemagick, but not essential
By the way, my current method for finding the local maxima in hough space:
dilate the hough space image ~3 times, then compare the dilated image with the original and set all pixels with differing values to zero. The remaining pixels are local maxima
Works very well.
edit:
I stumbled upon this implementation of a classic hough transform, which uses numpy instead of opencv, and apparently uses some numpy and python tricks to speed it up
http://mail.scipy.org/pipermail/scipy-u ... achment.py