问题
I have little background knowledge of image processing and recognition. I am trying to detect principal edges/grayscale transitions on a grayscale image such as a portrait. The problem is that on some parts, the edge is blurred (because of focus). I am using Canny edge detector with multiple thresholds, but I can never detect those edges (chin, clothes, ears, side of the face, ...)
Original image: This is the result I am getting: beard, sharp edges This is what features I'm interested in: transitions between the main gray areas
Is edge detection the right tool for this? Thanks!
UPDATE: Using Deriche filtering and halving the size of the image before edge detection (with apertureSize=7), I got it working pretty close to what I want.
回答1:
Using canny-deriche filter you can find :
Full code is here
回答2:
Its nearly impossible to detect those edges, since they are blurred out so much.
Edge detection works by analyzing rapid changes in color in the surrounding pixels. A blur smoothens out the pixels, which makes the changes much less intensive, and thus no edges are detected.
You could try applying a strong sharpen filter before the edge detection, however, I think for this amount of blur, edge detection won't work as intended.
Even if you raise the edge detection parameters to also detect those blurry edges, you will get a lot of false positives, making the algorithm useless.
回答3:
The only thing I can think of is to basically crop the area, and apply a Fourier (DFT). Then separate the pixels on the basis of an amplitude threshold, hold the pattern and apply it to your primary image (or just use Reverse Fourier). Alternatively, you could try and do this on an exponential scale, so as to widen the gap between the value of the pixels corresponding to your background and those corresponding to the image.
Of course, all these suggestions would be one-off solutions tailored for a single photo, or a series of photos taken under the same condition (e.g. something like an MRI).
I don't really see very many possibilities for doing this in a fully automatic way.
ANN solutions
If wanna resort to ANN (Artificial Neural Networks) and design one, which of course does not guarantee success, but it would - at least in principle - depend on how well it is designed. If you'd like to gain more insight into the use of ANN in complex image processing, read this conference paper from IEEE.
T. Kondo, J. Ueno, and S. Takao. Medical Image Recognition of Abdominal Multi-organs by Hybrid Multi- layered GMDH-type Neural Network Using Principal Component-Regression Analysis. In Second International Symposium on Computing and Networking (CANDAR), pages 157–163. Institute of Electrical and Electronics Engineers, IEEE, Dec. 2014.
Custom filters and mathematical principles
Here is some mathematical principles that you might find handy:
It is worth trying a custom filter, such as:
-------------
| 1 | 2 | 1 |
-------------
| 0 | 0 | 0 |
-------------
|-1 |-2 | 1 |
-------------
Notice that this won't filter any (fully) vertical line. You may, however, transpose it, so it would be the reverse. You may also try applying your filter on a binary image (black and white), as opposed to grayscale.
For such a filter, you might still want to you Fourier to reduce your computations and optimise the programme.
Principally, you could explain a linear filtering in terms of convolution as:
Y = f[X; G] = X ⓧ G_{flip}
where G is the kernel/mask and G_{flip} is flipped kernel mask.
Convolution
The definition of convolution in 2D would be:
X ⓧ G = Summation(∞, k=-∞){Summation(∞, l=-∞) x[i-k, j-l].G[k,l]}
This is not a complete answer to your question, but I hope it helps you to an extent.
来源:https://stackoverflow.com/questions/36970015/blurry-edge-detection