# How to remove noise using morphological filtering

I have two groups of dots that both contain noise between them:

The line that separates the two groups in the picture is diagonal in shape. I tried to use morphological filtering on this image to remove the noise between these two groups but failed.

This is the code that I tried to run on this image:

from skimage.morphology import opening, square

new_image = opening(image, square(3))


It did remove a little bit of noise, but not enough for them to become two distinct groups.

I am using DBSCAN on the new_image and DBSCAN still treats them as one group.

I would like to know whether I am giving the correct argument to the function opening. Or maybe there is some other way (better way) to remove the noise between the two groups?

• DBSCAN definitely can do this with the right parameters, but dinner of the points on the right will be noise. But for a single image you don't need such automatization at all - how many such images do you have? – Has QUIT--Anony-Mousse Sep 15 '19 at 6:59
• I have 6400 images – tamarlev Sep 15 '19 at 19:05
• can you tell me what parameters dbscan should be provided to separate it to two groups? – tamarlev Sep 15 '19 at 19:12
• Well, there will always be the split of group in the bottom left, too. There are many parameter settings that are good. I'd try radius 3 and minpts 10 for example, but why don't you just try some values - this is 2d pixels, you can find good values just by counting or ticking boxes in paper. Then show so!e difficult images along with the best results you got. – Has QUIT--Anony-Mousse Sep 15 '19 at 22:59
• dbscan do not contains parameters as radius or minpts, it contains eps, min_samples, metric etc' – tamarlev Sep 16 '19 at 5:17