MATLAB: Image Segmentation on an Image with low contrast and nonuniform lighting

image processingimage segmentationnon-uniform lightingshadowing

The image I'm working with looks like water droplets on a sheet of metal. What I'm trying to do is obtain statistics, such as blob area and centroidal distance of the shapes. I have figured out all of the code to accomplish this, but my code is lacking in the image processing department.
Shadowing has become a factor and due to the non-uniform lighting, it is difficult to do contrast adjustment effectively enough to separate the blobs from the background.
The process I have employed so far to segment the image is to:
(1) adjust the contrast of the image using imadjust
(2) apply a median filter to the image using medfilt2
(3) apply a top-hat filter using a structuring element imtophat(IM, se)
(4) adjust the contrast again using imadjust
(5) threshold the image into a binary using a decision statement
(6) morphologically open the image using bwareaopen and fill in holes using imfill
As of now, my code is able to pick out nearly all of the blobs in the image, but the centroids are obviously skewed, mostly due to shadowing I would guess. The blob area also may be a little skewed, which I think can be attributed to all of the complications that I've listed so far.
I would like to know if there are any suggestions for improving this process or maybe changing it completely. Thank you!

Best Answer

The imadjust() calls are not really necessary. I'm not sure what your image looks like since you didn't upload it, or tell us where it was. I assume steps 7 was a call to regionprops(). Other than that, it's probably okay. See my image segmentation tutorial if you want to see how I do it for one kind of image (with uniform background): http://www.mathworks.com/matlabcentral/fileexchange/?term=authorid%3A31862
Skewed distributions is normal for particle size analysis. They almost always show a log-normal or Lorentzian shape no matter what measurement you're looking at. There's even theory that says why (ref: http://search.barnesandnoble.com/Particle-Size-Measurement/Terence-Allen/e/9780412729508, which is the bible of particle size analysis) Don't expect that you'll get textbook perfect Gaussian-looking distributions - it almost never happens. They're almost always skewed.
The locations of your centroids may be shifted due to shadowing issues. That's why it's always best to try to correct image capture problems first rather than try to compensate for them during post processing.
Related Question