Saturday, November 11, 2017

filters - Recover myself from Dilate and Erode for noise reduction


i have obtained some skin detection map (i post below two example of detection map). but, i'm using a normal webcam and the map is noisy. Not a lot, just a bit.



I think i can remove noise only with some combination of dilate and erode, and then threshold it.


But, like a stupid child, i have spent hours in trying to set parameters, use in different combination like: dilate twice, erode three times, blur, and an erode again and so on.


The only result i have obtained is to lost myself: it is not a robust approach at all.


So, for image like this, how can i use those super-popular filters? Or some advice for getting a nice contour of the face and removing the noise?


enter image description here


EDIT:


Those two are two different approach to skin recognition: backprojection and mahalonobis distance, using as training data the output of a simple haar face detection. I'm using both of them because with some illumination setting the first is better, for others the second is better. For my porpouse i can choose the best anytime I'm using my application.



Answer



This is more of an extension to the ideas mentioned by @Dima and @heltonbiker.


As @heltonbiker said, it might be a good idea to apply thresholding first: I would be more confident this is the right approach if the images you posted were a bit bigger so I could examine the details for myself. Adaptive thresholding is one that is (more or less) robust to background illumination changes, and there's a good post here that you can use as a starting point.



@Dima suggested opening and closing as higher order morphological operations: they are just one step more complicated than erosion and dilation. You should definitely try approaches from the simpler to the more complicated, so I would try his idea first.


But, in case that does not give satisfactory results (be prepared, nothing will give perfect results), let me suggest two morphological approaches that are a tad more complicated:




  • first one is area closing and opening, specific types of algebraic openings and closings. They remove bright/dark elements not by direct application of a structuring element, but rather operate on shapes who satisfy a certain criterion (e.g. size $\ge$ or $\le 100$ pixels).


    A successful implementation of an area closing would, for example, allow you to fill all the black structures with a size smaller that a threshold completely, while leaving the bigger black structures intact.


    I have talked briefly about that in this SO answer (second bulet), and this article/chapter looks useful (although I've never read it): M. Van Droogenbroeck: Anchors of morphological operators and algebraic openings.




  • second one is applying alternating sequential filters. They're nice filter filters that treat dark and bright noise equivalently, so you should use them if that's the case. It also tries to "prevent" the removal of bright noise to remove bright objects (the same for dark noise/objects).



    First, let me define sequential filters: it's nothing more than simply applying sequential application of opening and closing with an elementary structuring element for the grid in a combination of orders:


    $ m_i = \gamma_i \phi_i$; $n_i = \phi_i \gamma_i $


    $r_i = \phi_i \gamma_i \phi_i $; $s_i = \gamma_i \phi_i \gamma_i $


    where $\gamma_i$ is an opening and $\phi_i$ a dual closing. The index $i$ indicates the size of the structuring element.


    Sequential filters by itself are sometimes enough: remove bright and then dark specks of certain size (or reverse order). Sometimes, however, if the SE size is not big enough, some things don't get cleaned, while if it's too big, removing bright specks messes with the bright structures. Here, alternating sequential filters come in to play: you start with a small, precise SE and then gradually increase SE size you work with. Note, this means multiple openings and closings, so it's a slow operation.


    The general idea to construct an alternating sequential filter is:


    $M_i$ = $m_i \cdots m_2 m_1$, and equivalent for other sequential filters.


    Some references: discussion that lead to pseudocode in MATLAB, as well as an article that seems useful: S. Pei, C. Lai: An Efficient Class of Alternating Sequential Filters in Morphology





I drew all my explanations from a book P. Soille: Morphological Image Analysis, but since it's a book, not an article, I didn't find a readily accessible PDF copy.


No comments:

Post a Comment

digital communications - Understanding the Matched Filter

I have a question about matched filtering. Does the matched filter maximise the SNR at the moment of decision only? As far as I understand, ...