I am trying to implement an algorithm for finding the zero crossing (check that the signs of all the entries around the entry of interest are not the same) in a two dimensional matrix, as part of implementing the Laplacian of Gaussian edge detection filter for a class,
I understand everything up to step 3 of page 25 of this PDF. Why do I have to compare the absolute values of my neighbouring entries? It doesn’t seem logical to me. If I have a matrix that looks like this:
[1 1 -2],
[2 -4 -1],
[1 -2 -2]
Why isn’t the value of -4 a valid zero crossing?
0
According to this website, this comparison is used to determine where exactly the zero crossing is if it seems to occur between two pixels. If there are multiple valid edges, which one is closest to the boundary? Obviously, the one with the smallest absolute value is the one closest to the zero crossing! There are many other ways to localize the edge, some of them summarized on the website I linked and probably many others found at your local library in an image processing textbook.
That being said, please note that the algorithm for edge detection in the previous OP actually will give you very sparse edges, as I’ve demonstrated by implementing the algorithm here. If you want continuous edges, although admittedly with a lot of false detections, you can use the following simplified algorithm.
- Check if all the pixels around you have the same sign.
- If they don’t have the same sign, then you are a zero crossing.
The code where I implement this is here.
In the end, if you want really good localization, you’re going to have to go to the sub-pixel scale, which unfortunately, I can’t help you with, but is covered in this paper. Alternatively, you might want to also try increasing the size of your zero-crossing detection range of consideration. In the end, the one thing to take away from all this, is that if you’re going to do edge detection, just stick with Canny.