Файл src/warper.c

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "allheaders.h"

Макросы

#define USE_SIN_TABLE   0

Функции

static l_float64generateRandomNumberArray (l_int32 size)
static l_int32 applyWarpTransform (l_float32 xmag, l_float32 ymag, l_float32 xfreq, l_float32 yfreq, l_float64 *randa, l_int32 nx, l_int32 ny, l_int32 xp, l_int32 yp, l_float32 *px, l_float32 *py)
PIXpixSimpleCaptcha (PIX *pixs, l_int32 border, l_int32 nterms, l_uint32 seed, l_uint32 color, l_int32 cmapflag)
PIXpixRandomHarmonicWarp (PIX *pixs, l_float32 xmag, l_float32 ymag, l_float32 xfreq, l_float32 yfreq, l_int32 nx, l_int32 ny, l_uint32 seed, l_int32 grayval)

Макросы

#define USE_SIN_TABLE   0


Функции

static l_int32 applyWarpTransform ( l_float32  xmag,
l_float32  ymag,
l_float32  xfreq,
l_float32  yfreq,
l_float64 randa,
l_int32  nx,
l_int32  ny,
l_int32  xp,
l_int32  yp,
l_float32 px,
l_float32 py 
) [static]

applyWarpTransform()

Notes: (1) Uses the internal sin function.

static l_float64 * generateRandomNumberArray ( l_int32  size  )  [static]

PIX* pixRandomHarmonicWarp ( PIX pixs,
l_float32  xmag,
l_float32  ymag,
l_float32  xfreq,
l_float32  yfreq,
l_int32  nx,
l_int32  ny,
l_uint32  seed,
l_int32  grayval 
)

pixRandomHarmonicWarp()

Input: pixs (8 bpp; no colormap) xmag, ymag (maximum magnitude of x and y distortion) xfreq, yfreq (maximum magnitude of x and y frequency) nx, ny (number of x and y harmonic terms) seed (of random number generator) grayval (color brought in from the outside; 0 for black, 255 for white) Return: pixd (8 bpp; no colormap), or null on error

Notes: (1) To generate the warped image p(x',y'), set up the transforms that are in getWarpTransform(). For each (x',y') in the dest, the warp function computes the originating location (x, y) in the src. The differences (x - x') and (y - y') are given as a sum of products of sinusoidal terms. Each term is multiplied by a maximum amplitude (in pixels), and the angle is determined by a frequency and phase, and depends on the (x', y') value of the dest. Random numbers with a variable input seed are used to allow the warping to be unpredictable. A linear interpolation is used to find the value for the source at (x, y); this value is written into the dest. (2) This can be used to generate 'captcha's, which are somewhat randomly distorted images of text. A typical set of parameters for a captcha are: xmag = 4.0 ymag = 6.0 xfreq = 0.10 yfreq = 0.13 nx = 3 ny = 3 Other examples can be found in prog/warptest.c.

PIX* pixSimpleCaptcha ( PIX pixs,
l_int32  border,
l_int32  nterms,
l_uint32  seed,
l_uint32  color,
l_int32  cmapflag 
)

pixSimpleCaptcha()

Input: pixs (8 bpp; no colormap) border (added white pixels on each side) nterms (number of x and y harmonic terms) seed (of random number generator) color (for colorizing; in 0xrrggbb00 format; use 0 for black) cmapflag (1 for colormap output; 0 for rgb) Return: pixd (8 bpp cmap or 32 bpp rgb), or null on error

Notes: (1) This uses typical default values for generating captchas. The magnitudes of the harmonic warp are typically to be smaller when more terms are used, even though the phases are random. See, for example, prog/warptest.c.


Документация по Leptonica. Последние изменения: Fri Aug 7 20:31:38 2009. Создано системой  doxygen 1.5.9