Файл src/rotate.c

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

Функции

PIXpixRotate (PIX *pixs, l_float32 angle, l_int32 type, l_int32 incolor, l_int32 width, l_int32 height)
PIXpixEmbedForRotation (PIX *pixs, l_float32 angle, l_int32 incolor, l_int32 width, l_int32 height)
PIXpixRotateBySampling (PIX *pixs, l_int32 xcen, l_int32 ycen, l_float32 angle, l_int32 incolor)

Переменные

static const l_float32 VERY_SMALL_ANGLE = 0.001

Функции

PIX* pixEmbedForRotation ( PIX pixs,
l_float32  angle,
l_int32  incolor,
l_int32  width,
l_int32  height 
)

pixEmbedForRotation()

Input: pixs (1, 2, 4, 8, 32 bpp rgb) angle (radians; clockwise is positive) incolor (L_BRING_IN_WHITE, L_BRING_IN_BLACK) width (original width; use 0 to avoid embedding) height (original height; use 0 to avoid embedding) Return: pixd, or null on error

Notes: (1) For very small rotations, just return a clone. (2) Generate larger image to embed pixs if necessary, and place in the center. (3) Rotation brings either white or black pixels in from outside the image. For colormapped images where there is no white or black, a new color is added if possible for these pixels; otherwise, either the lightest or darkest color is used. In most cases, the colormap will be removed prior to rotation. (4) The dest is to be expanded so that no image pixels are lost after rotation. Input of the original width and height allows the expansion to stop at the maximum required size, which is a square with side equal to sqrt(w*w + h*h). (5) Let theta be atan(w/h). Then the height after rotation cannot increase by a factor more than cos(theta - |angle|) whereas the width after rotation cannot increase by a factor more than sin(theta + |angle|) These must be clipped to the maximal side, and additionally, we don't allow either the width or height to decrease.

PIX* pixRotate ( PIX pixs,
l_float32  angle,
l_int32  type,
l_int32  incolor,
l_int32  width,
l_int32  height 
)

pixRotate()

Input: pixs (1, 2, 4, 8, 32 bpp rgb) angle (radians; clockwise is positive) type (L_ROTATE_AREA_MAP, L_ROTATE_SHEAR, L_ROTATE_SAMPLING) incolor (L_BRING_IN_WHITE, L_BRING_IN_BLACK) width (original width; use 0 to avoid embedding) height (original height; use 0 to avoid embedding) Return: pixd, or null on error

Notes: (1) Rotation is about the center of the image. (2) For very small rotations, just return a clone. (3) Rotation brings either white or black pixels in from outside the image. (4) Above 20 degrees, if rotation by shear is requested, we rotate by sampling. (5) Colormaps are removed for rotation by area map and shear. (6) The dest can be expanded so that no image pixels are lost. To invoke expansion, input the original width and height. For repeated rotation, use of the original width and height allows the expansion to stop at the maximum required size, which is a square with side = sqrt(w*w + h*h).

*** Warning: implicit assumption about RGB component ordering ***

PIX* pixRotateBySampling ( PIX pixs,
l_int32  xcen,
l_int32  ycen,
l_float32  angle,
l_int32  incolor 
)

pixRotateBySampling()

Input: pixs (1, 2, 4, 8, 16, 32 bpp rgb; can be cmapped) xcen (x value of center of rotation) ycen (y value of center of rotation) angle (radians; clockwise is positive) incolor (L_BRING_IN_WHITE, L_BRING_IN_BLACK) Return: pixd, or null on error

Notes: (1) For very small rotations, just return a clone. (2) Rotation brings either white or black pixels in from outside the image. (3) Colormaps are retained.


Переменные

const l_float32 VERY_SMALL_ANGLE = 0.001 [static]


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