Undo The Twirl
I work in image analysis. The major advantage of this is that when I criticise shows like 24 and Spooks for their utterly preposterous image enhancement software I can do so with a vague air of authority. But it’s not usually very exciting; not the kind of science that they can make a CSI style show about (although I thought that about maths, and they went ahead and made Numb3rs anyway*). So I was glad to see a forensic image analysis story in the Times today. It is the story of a very stupid paedophile who photographed himself sexually abusing young boys and put the photos on the internet. To prevent his arrest, he fired up some art package or other and distorted his face until you couldn’t tell who it was.
He used a fairly standard distortion that most packages call “twirl” or “whirlpool”. This was not smart. Had he used “blur”, he’d still be loose. Had he used “pixellate”, he’d be on the streets. Those effects destroy image information. But he used “twirl”. The thing about “twirl” is that it’s technically a transform: it doesn’t remove any information from the picture, and that means you can reconstruct the original, with a little patience and preferably a copy of MATLAB. Unfortunately, my laptop with MATLAB installed is currently not working, so I can’t fire it up and show you how to do this, but I can explain it. First, here’s the image he released and the image the police reconstructed from it:
Image source: AFP
The effect is pretty simple, and you’ve probably already figured out how it’s done, but to make it explicit, here it is in mathematical terms. Working in polar coordinates, you shift the image in θ, where the shift (which we should call Δθ) depends on R. (If you’re not familiar with the notation, R is the distance from the centre of the swirl and θ is the angle that distance is at.) For full nerd points, here’s the equation:
θf = θi + S × f(R)
More generally it should be θf = θi + f(S, R), but the art package designers probably didn't set out to make this difficult. They probably didn't expect it would be used in this way.
I’ve used S as the strength of the effect that you get to choose. The simplest way to undo this effect is to simply apply the same distortion in the other direction: subtract S × f(R) and you get θi back. First we need to know where the centre of the swirl is, but that’s relatively simple. The patterning behind him shows us the edge of the circle, so finding the centre isn’t too hard, and that’s led to people (such as what is at the moment the only commenter on the Times article above) saying that this should have been an easy fire-up-PhotoShop-and-press-twirl fix. Problem is that all paint programmes use a slightly different f(R). So really you’re just left playing around with something like MATLAB to find a f(R) that works. That’s why the reconstructed image above still looks a bit like he’s hypnotising you with his Scary Eye.
My preferred approach would be to knock up a MATLAB interface that let me draw a f(R) on a pair of axes and then showed me the image it resulted in. I reckon I could detwirl that image to a recognisable whole in an afternoon. And yet…
The hunt began three years ago when German police discovered about 200 photos on the internet of a man sexually abusing young Asian boys. But the man's face had been digitally scrambled and it was only 11 days ago that German police were finally able to reconstruct an identifiable image of the man who had eluded them for so long.
I can’t imagine how you could spend three years on that. If you can’t do it to a good approximation in a week then it’s probably impossible, and if you can then I don’t see how there could be three years of work in it.
There are 200 images, of course, but it’s safe to assume he’s used the same software to do each one. There aren’t many distorts that don’t destroy the image information, so probably many of those images were useless. The rest, you can reconstruct in the same way. They’ll use the same f(R).
It’s not as simple as it looks at first glance, but… I just can’t see three years’ work in that. Doing it in a couple of months would have got him caught much sooner. Also now, of course, they have to computer-graphically age the image three years.
Well. Perhaps if my laptop is mended I shall have a go and see how hard it actually is, and then I’ll be able to say properly. But probably by the time my laptop gets fixed I shall be too distracted by the flying pigs and so forth.
Still, it could happen.
*I’m given to understand that the maths in Numb3rs was mostly pretty good, although they did approximate e to three.