Depix is a PoC for a technique to recover plaintext from pixelized screenshots.
This implementation works on pixelized images that were created with a linear box filter. In this article I cover background information on pixelization and similar research.
tool_show_boxes.py
to show how bad the box detector is (you have to really cut out the pixels exactly). Made a TODO to create a version that just cuts out boxes of static size.python3 depix.py \
-p /path/to/your/input/image.png \
-s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png \
-o /path/to/your/output.png
python3 depix.py \
-p images/testimages/testimage3_pixels.png \
-s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png
Result:
python3 depix.py \
-p images/testimages/sublime_screenshot_pixels_gimp.png \
-s images/searchimages/debruin_sublime_Linux_small.png \
--backgroundcolor 40,41,35 \
--averagetype linear
Result:
tool_show_boxes.py
. Consider a smaller batch of pixels if this looks all mangled. Example of good looking boxes:python3 tool_show_boxes.py \
-p images/testimages/testimage3_pixels.png \
-s images/searchimages/debruinseq_notepad_Windows10_closeAndSpaced.png
tool_gen_pixelated.py
.python3 tool_gen_pixelated.py -i /path/to/image.png -o pixed_output.png
$ python3 depix.py -h
and tool_gen_pixelated.py
.images/searchimages/
.-s
flag set to the location of this screenshot.testimages
for examples.tool_show_boxes.py
script and different cutouts if your blocks aren't properly detected.The algorithm uses the fact that the linear box filter processes every block separately. For every block it pixelizes all blocks in the search image to check for direct matches.
For some pixelized images Depix manages to find single-match results. It assumes these are correct. The matches of surrounding multi-match blocks are then compared to be geometrically at the same distance as in the pixelized image. Matches are also treated as correct. This process is repeated a couple of times.
After correct blocks have no more geometrical matches, it will output all correct blocks directly. For multi-match blocks, it outputs the average of all matches.
Create more averaging filters that work like some popular editors do.
After creating this program, someone pointed me to a research document from 2016 where a group of researchers managed to create a similar tool. Their tool has better precision and works across many different fonts. While their original source code is not public, an open-source implementation exists at DepixHMM.
Edit 16 Feb '22: Dan Petro created the tool UnRedacter (write-up, source) to crack a challenge that was created as a response to Depix!
Still, anyone who is passionate about this type of depixelization is encouraged to implement their own HMM-based version and share it.