Having difficulties detecting small objects in noisy background. Any ways to fix this?

此生再无相见时 提交于 2019-12-04 05:49:18

what i am understanding from your problem is: you want to segment out the foreground objects from a background which is variable in nature(sand gray level is depending on many other conditions).

there are various ways to approach this kind of problem:

Approach 1:

From your image one thing is clear that, background color pixels will always much more in numbers than foreground, simplest method to start initial segmentation is:

  1. Convert the image into gray.
  2. Create its histogram.
  3. Find the peak index of the histogram, i.e. index which have maximum pixels.

above three steps give you an idea of background BUT the game is not ends here, now you can put this index value in the center and take a range of values around it like 25 above and below, for example: if your peak index is 207 (as in your case) choose a range of gray level from 75 to 225 and threshold image, As according to nature of your background above method can be used for foreground object detection, after segmentation you have to perform some post processing steps like morphological analysis to segment out different objects after extraction of objects you can apply some classification stuff for finer level of segmentation to remove false positive.

Approach 2:

Play with some statistics of the image pixels, like make a small data set of gray values and

  1. Label them class 1 and 2, for example 1 for sand and 2 for foreground,
  2. Find out mean and variance(std deviation) of pixels from both the classes, and also calculate probability for both the class ( num_pix_per_class/total_num_pix), now store these stats for later use,
  3. Now come back to image and take every pixel one by one and apply a gaussian pdf: 1/2*pisigma(exp(-(pix - mean)/2*sigma)); at the place of mean put the mean calculated earlier and at the sigma put std deviation calculated earlier.
  4. after applying stage 3 you will get two probability value for each pixel for two classes, just choose the class which have higher probability.

Approach 3:

Approach 3 is more complex than above two: you can use some texture based operation to segment out sand type texture, but for applying texture based method i will recommend supervised classification than unsupervised(like k-means). Different texture feature which you can use are:

Basic:

  1. Range of gray levels in a defined neighborhood.
  2. local mean and variance or entropy.
  3. Gray Level Co-occurrence Matrices (GLCM).

Advanced:

  1. Local Binary Patterns.
  2. Wavelet Transform.
  3. Gabor Transform. etc.

PS: In my opinion you should give a try to approach 1 and 2. it can solve lot of work. :)

For better results you should apply many algorithms. The OpenCV-tutorials focus always on one feature of OpenCV. The real CV-applications should use as many as possible techniques and algorithms.

I've used to detect biological cells in noisy pictures and I gained very good results applying some contextual information:

  • Expected size of cells
  • The fact that all cells have similar size
  • Expected number of cells So I changed many parameters and tried to detect what I'm looking for.

If using edge detection, the sand would give rather random shapes. Try to change the canny parameters and detect lines, rects, circles, ets. - any shapes more probable for litter. Remember the positions of detected objects for each parameters-set and at the and give the priority to those positions (areas) where the shapes were detected most times.

Use color-separation. The peaks in color-histogram could be the hints to the litter, as the distribution of sand-colors should be more even.

For some often appearing, small objects like cigarette-stubs you can apply object matching.

P.S: Cool application! Jus out of curiosity, are yoou going to scan the beach with a quadcopter?

If you want to detect objects on such uniform background, you should start by detecting the main color in the image. Like that you will detect all the sand, and the objects will be in the remaining parts. You can take a look to papers published by Arnaud LeTrotter and Ludovic Llucia who both used this type of "main color detection".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!