We have all tried to take a picture through a window of a gorgeous view, only to have our own mug reflected back in the photo.

Now researchers from the Massachusetts Institute of Technology have a possible fix for this. Using the fact that photos taken through double-pane glass windows nearly always contain two almost identical, slightly shifted reflections, the team, led by YiChang Shih, have developed an algorithm that can automatically remove the unwelcome "ghosted" element from a digital photo.

See also: Enlight wants to be a Swiss Army knife for mobile photo editing

The algorithm, building on work done by Daniel Zoran and Yair Weiss of the Hebrew University of Jerusalem, divides images into 8-by-8 blocks of pixels and determines each pixel's correlation with another. Their technique is able to identify which minuscule sections of the photo are part of the reflection and which are the actual image seen behind the glass.

Image: Courtesy of the researchers

“The ideas here can progress into routine photography, if the algorithm is further robustified and becomes part of toolboxes used in digital photography,” Yoav Schechner, a professor of electrical engineering at Israel’s Technion, said in a statement from MIT. He also suggested that with refinement, the software could help robot vision determine whether it is seeing a reflection or through glass.

So, this technology is a mixed bag: It could help your Instagram game, but it could also create peeping-tom robots.