Use color-based segmentation to find a uniform color background
Choose an image with a daytime background and a nighttime background to replace it with:
In[1]:=
i=
;bg=
;
Use a Chan-Vese segmentation method to find the background of the giraffe image, looking for colors close to light blue, and automatically choosing the foreground color: