Search code examples
opencvimage-processingimage-recognitionedge-detectionnoise-reduction

Feature detection on a small, noisy image with OpenCV


I have an image that is both pretty noisy, small (the relevant portion is 381 × 314) and the features are very subtle.

relevant area

The source image and the cropped relevant area are here as well: https://i.sstatic.net/mVLFx.jpg

The task is to count the number of white-ish dots within the relevant area using Python but I would be happy with just isolating the lighter dots and lines within the area and removing the background structure (in this case the cell).

With OpenCV I've tried Histogram equalization (destroys the details), finding contours (didn't work), using color ranges (too close in color?)

Any suggestions or guidance on other things to try? I don't believe I can get a higher res image so is this task possible with the rather difficult source?


Solution

  • (This is not a Python answer, since I never used the Python/OpenCV binding. The images below were created using Mathematica. But I just used basic image processing functions, so you should be able to implement that in Python on your own.)

    A very general "trick" in image processing is to think about removing the thing you're looking for, instead of actually looking for it. Because often, removing it is much easier than finding it. You could for instance apply a morphological opening, median filter or a gaussian filter to it:

    enter image description here

    These filters effectively remove details smaller than the filter size, and leave the coarser structures more or less untouched. So you can just take the difference from the original image and look for local maxima:

    enter image description here

    (You'll have to play around with different "detail removal filters" and filter sizes. There's no way to tell which one works best with just one image.)