What's the best way to reproduce a Captcha distortion?


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 ...


1/20/2019 2:32:00 PM

Accepted Answer

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

4/17/2014 8:07:00 AM

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.