# Removing uncommon objects from bunch of images

The problem I am facing is the following:

I want to take a picture of the entrance to a building. I fix the camera on a tripod stand and place the stand on the footpath in front of the building. The problem is that a some people always keep passing between the camera and the entrance, thereby obstructing the view of the camera. I want a "perfect image", that is without any people (only the building will appear). So I decided to take $20$ pictures without changing the camera location, trying to time them right to avoid people coming into the photograph frame. However, none of the pictures is “perfect”, i.e., there is always one or two persons somewhere in the frame. The persons can be randomly anywhere in the frame. Now I want to get a "perfect image" from this set of “imperfect” pictures automatically, without any human intervention.

I thought about an algorithm like this:

Since I have $20$ values for each pixel in the image, I will keep the pixel values which are unchanged over all the $20$ images and for the pixels where there are more than $1$ pixel values for a particular user, I will keep the value which is the mode of those $20$ values. i.e. whichever value appears the most number of times.

Are there any better/robust methods of doing this? Because currently, I am not using any kind of image processing here, I am just using a heuristic algorithm based on common sense.

• Since your goal is to obtain a 'clean' image but not detecting these objects, using the mode would be the simplest way to go. Since you are using a tripod, if you do not have a lot of variations in illumination, you might even get away with averaging images directly. – Tyathalae Oct 4 '17 at 13:44