3

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?

1
  • 1
    I suggest you look into CLAHE. This might help with the "destroys details" problem. OpenCV has an implementation, but it's not documented (sadly). Commented Jun 18, 2014 at 19:34

1 Answer 1

12

(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.)

Sign up to request clarification or add additional context in comments.

7 Comments

Pure genius. I stared at that cell for an hour trying to think of a way to get the dots and never thought about getting the background! I'll try this process in OpenCV. Thank you so much!
@Nikie Could you increase the font size of the annotation a bit bigger? I can hardly read it. Which one did you apply to get the red dots?
@kkuilla: You can open the images in a separate tab. (The images are downsampled inline). I used the median result for the red crosses - but the results with opening/gaussian look qualitatively similar.
I can't open a new tab, I'm afraid. Don't know why. You could set the font size to something really large, like 36 or 48. Then it will look ok when downsampled. It's a nice answer anyway. +1
@PFM: Actually, I just used ImageData and -, i.e. I turned the image into a 2d array and did the arithmetic with that. I guess the equivalent in Python would be to convert a PIL image into a NumPy array.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.