What would be the simplest way to distort a text (or image) as in the captchas we see online. Formerly I would model a wavy 3D surface, apply the text/image as a texture and render it. There must be a better way ...


  • Just to be sure: You talk about writing a program to create CAPTCHA images - and not only create some example images manually, right? Apr 17, 2014 at 7:59
  • In addition to the answers provided, captcha/recaptcha are libraries for server software. You could easily install a local web server package ("WAMP"/"LAMP") and generate your own using the actual captcha software.
    – horatio
    Apr 17, 2014 at 16:04

3 Answers 3


Not sure how many words your want to distort, but if it's not too many you could just use the Liquify tool in Photoshop.

Filter > Liquify

Then with the brush just push the text about until you're happy with it.

You will have to raster the text for it to work.

enter image description here

  • Ah, interesting - I think that Liquify is exactly the rubber sheet interpolation I wrote about in my answer, the point you moved with the mouse is one of the Cij, and the point you started the move is Pij. Apr 17, 2014 at 8:04
  • @VolkerSiegel Well I was unsure exactly how the OP wanted to produce the distorted text so it's best to give them as many viable options as possible :)
    – SaturnsEye
    Apr 17, 2014 at 8:08
  • 1
    Looks like these two answers are just the perfect combination! :) Apr 17, 2014 at 8:10
  • @crtn-hrd no problem!
    – SaturnsEye
    Apr 17, 2014 at 11:02

From a pure technical standpoint distortion is very easy to do. To understand this you have to realize that the image is a matrix stacked onto your screen. If we need to refer to a specific pixel its easiest to think of this pixel as having a coordinate in both x and y within the image filed. To visualize this let use normalize the coordinates to 0-1 range this makes it convenient to use as you can now view the data in the imaging application.

But what happens if this coordinate field is not even? The image then distorts. There are many tools that can do this because its a very basic operation at the look up level. 3D imaging applications can do this on a texture level as well as object distortion level. Nearly all imaging tools have this function, because its important if you want to use your image as data or manipulate pixels movement in any way (so without this tool you can not rotate images non 90 degree increments for example). A partial (really just a fraction) list of that I have used to induce distortion include: Photoshop, GIMP, ImageMagick, Aftereffects, Shake, Nuke, Fusion, Maya , 3DS Max, Blender, Mathematica.... Off course this is also pretty easy to program yourself. However, if you need to do this in a automated fashion look into using ImageMagic (see following technical explanation for a more thorough explanation on the subject).

But let us use a alternate approach for Photoshop (with no painting involved):

The text Data

Image 1: Original image

To distort the original image let us make a new image with the dimensions of the original divided 10 (or something like that). fill image with 50% gray and apply some Gaussian noise (maybe 25-50% noise). Scale the image up to the size of the original image. Save this image out as vector field.png or something. Back in the original image choose filter -> distort -> displace.., set the scales to something like 1-2, point it to the random noise you made. Now this is one way you could also use less pixels or stack 2 different sized pixel images on top of each other etc... Basically this is what the liquify does it makes a vector field.

Random image

Image 2: Vector field used for distortion

Distorted text

Image 3: result after the steps above have been completed.

Each time you do this the result is different. You can also do this with the Puppet warp tool in Photoshop and after effects for example.

It is also possible to do this for vector data itself. For example in Illustrator you could use Object -> Envelope Distort -> Make with mesh... But this is all i have time for, gotta go and do something else.


You basically need some mapping from the plain image P to the CAPTCHA image C that should have some nonlinear distortion, but, from the math side, be continuous, and "relatively harmless".

So I propose to not bother to use a strict model for the distortion, but start with a simple identity mapping the points Pij to Cij. If you don't map actual pixels, but points spaced about 15 image pixels or so, you can then "push around" these points by things like adding small random values to the Cij.

To create an actual pixel mapping from that, you could use some kind of rubber sheet interpolation. (Or any interpolation creating bad artifacts, which makes your CAPTCHA actually better)

  • Thanks also Volker ! At the moment I'm just looking for a manual way to distort (I wasn't clear about that), but what you proposed might be very useful for me in the future ! :)
    – crtn-hrd
    Apr 17, 2014 at 11:01
  • 1
    Ok, that's fine either way - I see the answer as "to you, and others who find it later" - so it may still be useful to someone searching for the question title :) Apr 17, 2014 at 11:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.