An Easy Way to Remove Tourists from Photos

Quick Success Data Journalism

Image cleanup with Python, PIL, and OpenCV

8 min read

12 hours ago

Photo of the Taj Mahal by DALL-E3

If you take photographs of famous landmarks or do any astrophotography, you’re probably aware of image stacking. This is a process where you take many stationary pictures and then stack (average) them together to remove noise or other unwanted elements.

These techniques can remove anything that moves at a photo site, including people. Adobe Photoshop, for example, has a “crowd removal” script that magically vanishes nonstationary objects. It relies on a statistical average known as the median, which is simply the “middle” value in a list of numbers arranged from smallest to largest.

The process requires multiple photos. These are preferably taken with a tripod-mounted camera so that the objects you want to remove change positions from one image to the next, while the background remains constant. You typically need 10 to 30 pictures taken about 20 seconds apart, or similarly spaced frames extracted from a video.

With the mean, you sum numbers and divide by the total. With the median, you sort numbers and choose the middle value.

In the following figure, a row of five images is shown with the same pixel location outlined in…