How to detect 45 degree faces in an image

If instead of getting all the edges, I want only edges that have an angle of 45 degrees. What is the method of detecting them?

Is it possible to detect all the edges, then somehow start the limited hough transformation to determine which edges form 45 degrees?

+6
source share
3 answers

What is wrong with using an element of diagonal structure and just convolution of the image

More details

Please read here , and it should become clear how to build the structuring element. If you are familiar with convolution, you can build a simple structural matrix that reinforces diagonals without theory

{ 0, 1, 2}, {-1, 0, 1}, {-2, -1, 0} 

The idea is this: you want to reinforce a pixel in the image, where the 45deg below it is something different from the 45deg above it. This is the case when you are on the verge of 45 degrees.

Example. Next image

enter image description here

minimized by the matrix above gives a graylevel image where the highest pixel values ​​are those lines that are 45deg.

enter image description here

Now the approach is to simply binarize the image. Et voila

enter image description here

+4
source

If you use the kernel but want linear equations, you still have to snap the line after the edge pixels are found. If you are sure that the lines have exactly 45 degrees, then knowing the point (x, y) on any detected line or line segment is enough to find a linear equation.

the Hough parameter space (rho, theta) can use any rho and theta ranges you want. You can pre-process the image to maintain neighboring pixels at the right angle. For example, bring the “bonus point” to the edge pixel if it has 8 neighbors at an appropriate angle. You can, of course, mix a kernel-based method (such as the one proposed by halirutan) with or without the Hough parametric algorithm.

A recent implementation of Hough runs at fast speeds, so if you are looking for a quick solution, you can download open source and then just filter the output.

"Real-time line detection through an advanced Hough transform voting scheme" Fernandez and Oliveira http://www.ic.uff.br/~laffernandes/projects/kht/index.html

+1
source

First of all, this can be done as post-processing. The result of Howe is in the parameter space (angle, radius). So you can just take a slice at say angle = (45-5.45 + 5) and all radii.

An alternative method is that the edge detection output will contain only 45/135 angular angles.

0
source

Source: https://habr.com/ru/post/903988/


All Articles