How to identify points that are very different from their neighbors

I am involved in image processing, and I try to track dots similar to those that circled below, a very dark spot in a couple of pixel diameters, with all the neighboring pixels bright. I am sure that there are algorithms and methods that are designed for this, but I just don’t know what it is. I don't think edge detection will work, as I only need small spots. I got a little familiar with morphological operators, could this be a suitable approach?

thanks

wavelet filtered image

+7
c ++ algorithm image image-processing opencv
source share
9 answers

Personally, I like the angle detection algorithm .

You can also develop an algorithm for determining the naive search angle using the idea that an isolated pixel is a pixel through which the intensity changes dramatically in all directions. This is just the initial idea to start and move on to the best algorithms.

+1
source share

Scroll your pixel in your image. When you finish looking at the pixel, mark it as "used" (change it to some sentinel value or save this data in a separate array parallel to the image).

When you encounter a dark pixel, fill-fill it, marking all these pixels as “used” and keeping track of how many pixels have been filled. When filling the fill, make sure that if the pixel you are viewing is not dark, it is bright enough.

After filling the fill, you will know the size of the dark area that you filled, and whether the fill border was exceptionally bright pixels. Now continue the original loop, skipping the “used” pixels.

+5
source share

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

Then, if most of the neighbors are bright, the pixel becomes bright, etc.

Editing: after some thought, I realized that this will not detect outliers, it will delete them. So this is not the solution that the original poster asked about.

+3
source share

Are you sure you do not want to use the edge detection approach? It seems like comparing the current pixel with the average value of the neighborhood pixels would do the trick. (I would appreciate the different sizes of the surroundings to be sure.)

+2
source share

I can think of these methods that can work with some parameter setting:

+1
source share

I am going to offer a simple template for this if all your functions are about the same size.

Just copy the pixels of one (or several functions) to create several patterns, and then use the normalized cross-correlation or any other estimate that OpenCV provides in its pattern matching procedures to find similar regions. As a result, determine all the maximum response peaks (OpenCV also has a function for this), and these are your function coordinates.

+1
source share

It has been several years since I did image processing. But I will probably start by converting to binary representation. It doesn't seem like you are too interested in gray averages, only very dark / very light areas, so get rid of all the gray. At this point, various morphological operations can emphasize those points that interest you. Opening and closing is quite easy to implement and can give pretty nice results, leaving you with a black area everywhere except the points you are interested in.

0
source share

Have you tried extracting connected components using cvContours? The first image threshold (using the Otsu method), and then the extraction of each path. Since the spots you want to track (from what I see in your image) are somewhat isolated from the neighborhood, they will be like separate outlines. Now, if we calculate the area of ​​the bordering rectangle of each contour and filter out the larger ones, we will only have small dots separated from the dark neighbors. As suggested earlier, a little morphological mastery before separating the outline should give good results.

0
source share

Blur a (3x3) copy of your image and then compare the original image. The pixels with the highest values ​​are those that differ from their neighbors. This can be used as an edge detection algorithm, but the dots are similar to super-borders, so set the 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
source share

All Articles