One classic approach is using top hat filtering for leveling uneven illumination. You should perform morphological opening with a large structuring element, then remove the result from the original image. Edit: if
If you have dark objects on light background you should do bottom hat filtering (dual of top hat filtering): subtract the closing with a large structuring element from the original image.