9

I'm doing some image processing, and am trying to keep track of points similar to those circled below, a very dark spot of a couple of pixels diameter, with all neighbouring pixels being bright. I'm sure there are algorithms and methods which are designed for this, but I just don't know what they are. I don't think edge detection would work, as I only want the small spots. I've read a little about morphological operators, could these be a suitable approach?

Thanks

wavelet filtered image

1
  • Are you looking only for dark dots on bright background or also opposite (bright dots on dark background)? Aug 29, 2010 at 18:48

9 Answers 9

5

Loop over your each pixel in your image. When you are done considering a pixel, mark it as "used" (change it to some sentinel value, or keep this data in a separate array parallel to the image).

When you come across a dark pixel, perform a flood-fill on it, marking all those pixels as "used", and keep track of how many pixels were filled in. During the flood-fill, make sure that if the pixel you're considering isn't dark, that it's sufficiently bright.

After the flood-fill, you'll know the size of the dark area you filled in, and whether the border of the fill was exclusively bright pixels. Now, continue the original loop, skipping "used" pixels.

1
  • That's a nice approach, I'll try it
    – Simonw
    Aug 6, 2010 at 16:59
3

How about some kind of median filtering? Sample values from 3*3 grid (or some other suitable size) around the pixel and set the value of pixel to median of those 9 pixels.

Then if most of the neighbours are bright the pixel becomes bright etc.

Edit: After some thinking, I realized that this will not detect the outliers, it will remove them. So this is not the solution original poster was asking.

0
2

Are you sure that you don't want to do an edge detection-like approach? It seems like a comparing the current pixel to the average value of the neighborhood pixels would do the trick. (I would evaluate various neighborhood sizes to be sure.)

1

Personally I like this corner detection algorithms manual.

Also you can workout naive corner detection algorithm by exploiting idea that isolated pixel is such pixel through which intensity changes drastically in every direction. It is just a starting idea to begin from and move on further to better algorithms.

1
  • 404 on the link now, here's the wikipedia page for corner detection (I have no way of knowing if it covers similar information to the linked article): en.wikipedia.org/wiki/Corner_detection
    – dtudury
    Dec 1, 2015 at 19:39
1

I can think of these methods that might work with some tweaking of parameters:

1

I'm actually going to suggest simple template matching for this, if all your features are of roughly the same size.

Just copy paste the pixels of one (or a few features) to create few templates, and then use Normalized Cross Correlation or any other score that OpenCV provides in its template matching routines to find similar regions. In the result, detect all the maximal peaks of the response (OpenCV has a function for this too), and those are your feature coordinates.

1

Blur (3x3) a copy of your image then diff your original image. The pixels with the highest values are the ones that are most different from their neighbors. This could be used as an edge detection algorithm but points are like super-edges so set your threshold higher.

what a single off pixel looks like:
(assume surrounding pixels are all 1)

original  blurred         diff
1,1,1     8/9,8/9,8/9     1/9,1/9,1/9
1,0,1     8/9,8/9,8/9     1/9,8/9,1/9
1,1,1     8/9,8/9,8/9     1/9,1/9,1/9


what an edge looks like:
(assume surrounding pixels are the same as their closest neighbor)

original  blurred         diff
1,0,0     6/9,3/9,0/9     3/9,3/9,0/9
1,0,0     6/9,3/9,0/9     3/9,3/9,0/9
1,0,0     6/9,3/9,0/9     3/9,3/9,0/9
0

Its been a few years since i did any image processing. But I would probably start by converting to a binary representation. It doesn't seem like you're overly interested in the grey middle values, just the very dark/very light regions, so get rid of all the grey. At that point, various morphological operations can accentuate the points you're interested in. Opening and Closing are pretty easy to implement, and can yield pretty nice results, leaving you with a field of black everywhere except the points you're interested in.

0

Have you tried extracting connected components using cvContours? First thresholding the image (using Otsu's method say) and then extracting each contour. Since the spots you wish to track are (from what I see in your image) somewhat isolated from neighborhood they will some up as separate contours. Now if we compute the area of the Bounding Rectangle of each contour and filter out the larger ones we'd be left with only small dots separate from dark neighbors. As suggested earlier a bit of Morphological tinkering before the contour separation should yield good results.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.