0

If possible, can you point me to existing methods in the computer vision domain to achieve the following? Given a greyscale image, I want to apply a filtering algorithm such that only those components remain visible, which have an edge-like characteristic and a specific angle. For horizontal and vertical edges, I know that I can apply a median filtering approach but what about other angles (like 60°) Any hints are much appreciated.

Update #1: The idea is to filter out components of an audio spectrogram. Three categories I'm looking into are horizontal edges (harmonic overtones), vertical edges (percussive transients), but also diagonal structures like for the siren:

picture from publication

picture was taken from this publication

Update #2: As correctly pointed out by Chris Luengo, I was actually looking for lines (instead of edges), sorry of the mix-up. Still, I'm not just looking to detect them but to filter out all non-line content in a given 2D image

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36
noodle
  • 1
  • 1
  • Hope this helps https://stackoverflow.com/questions/52021576/finding-lines-with-that-has-specific-angles-in-python-open-cv – Jeru Luke Jul 01 '22 at 20:54
  • It would help if you showed a typical input image, and the expected output. From your description it is hard to understand exactly what you are after. – Cris Luengo Jul 02 '22 at 03:07
  • @CrisLuengo The idea is to filter out components of an audio spectrogram. Three categories I'm looking into are horizontal edges (harmonic overtones), vertical edges (percussive transients), but also diagonal structures like for the siren: https://www.researchgate.net/publication/341841037/figure/fig6/AS:898152009834500@1591147534232/Spectrograms-of-different-types-of-alarm-sounds-a-Alternating-alarm-usually-used-in.jpg – noodle Jul 02 '22 at 13:53
  • 1
    Those are not edges, they are lines. Look for line detection or ridge detectors. – Cris Luengo Jul 02 '22 at 14:40
  • Oh, please [edit] the details into the question, comments are easy to delete. – Cris Luengo Jul 02 '22 at 14:53

1 Answers1

0

For edges use Canny:

edges = cv2.Canny(image, 100, 240)

Next option is little bit tricky, i would go 2 way, and test wich wourk better for you:

1)Make Contours from that object, then detect, where contours change velocity, test that angle by normalized vectors of old vs new.

Start something like this, then test the each contour for that:

contoursext, hierarchy = cv2.findContours(
    edges, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE
#contoursext is list of contours, its clasic (x,y).

2)Detect Lines by using HoughLinesP more in this:

How to detect lines in OpenCV? Then detect, if lines are touching and you can calculate angle from the 2 normalized vectors of that lines.

Hope this will set you on right track, if you need more help, you should post image, what are you trying to do, I would post image examples.

Jakub
  • 174
  • 9
  • 1
    none of your suggestions address filtering for edges of certain angles. Canny is generally a bad recommendation. it is harmful in most cases people recommend it for. same goes for Hough transforms of all kinds. they're expensive. – Christoph Rackwitz Jul 02 '22 at 08:53
  • Yes, I've seen the CV methods for detecting particular edges (e.g. the structural tensor method). Here I have for instance a noisy version of the siren spectrogram (see my comment above) and I wonder what CV operation I can apply to filter out all components EXCEPT the diagonal edges – noodle Jul 02 '22 at 13:55
  • As clarified in the discussion above, I'm actually looking for lines (not edges), sorry for the mixup – noodle Jul 03 '22 at 07:55