When separating objects from a background in an image, we often meet difficulties to obtain the precise output due to the unclear edges of the objects as well as the poor or nonuniform illumination. In order to solve this problem, this paper presents an in situ segmentation method which takes advantages of the distribution feature of illumination of light sources, rather than analyzing the image pixels themselves. After analyzing the convexity of illumination distribution (CID) of point and linear light sources, the paper makes use of the CID features to find pixels belonging to the background. Then some background pixels are selected as control points to reconstruct the image background by means of B-spline; finally, by subtracting the reconstructed background from the original image, global thresholding can be employed to make the final segmentation. Quantitative evaluation experiments are made to test the performance of the method.